Re: Re: Uploading Photos to MySQL
| From: | Mike Gifford | Date: | Wed, 12 Sep 2001 15:18:51 +0000 |
| Subject: | Re: Re: Uploading Photos to MySQL | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-67053@lists.php.net to get a copy of this message | ||
Hi Sean,
Sean C. McCarthy wrote:
If you mean http://www.webtechniques.com/archives/1998/02/lerdorf/ what inserts in the DB is just the image's name, but not the file itself.I had trouble opening up the upload.php3 file in list six, so I couldn't verify by looking at the code. Not sure if it was the javascript or what, but I couldn't open it.
What is exactly the problem you are having with the class? Just a couple days ago I had a problem uploading files into a MySQL DB because the addslashes function. As I have seen in this code it also uses it. Your problem is with getting corrupt data from the DB?Add slashes are included as the file is added to the array: $this->daten["image"] = addslashes(fread(fopen($userfile, "r"), filesize($userfile))); Some content almost gets inserted. However it only gets as far as: Content-Type: image/jpeg ÿØÿà The image filed is just a blob
If it is this use base64_encode and base64_decode. This is a tip Chris (only know his name) gave me as no solution for addslashes was given... Thanks again Chris!!Ok.. This is getting better.. http://php.net/manual/en/function.base64-encode.php $this->daten["image"] = addslashes(base64_encode( fread(fopen($userfile, "r"), filesize($userfile)))); gives me quite a lot more information. Even looks like when I upload different images, that it is different information (unlike previous attempts) Unfortunately, it still isn't producing the graphic that I'm looking for... Hmm.. I get raw code easily enough: http://pgs.ca/WLP/profiles/getimage-simple.php3?imageID=16 http://pgs.ca/WLP/profiles/getimage-simple.php3?imageID=17 http://pgs.ca/WLP/profiles/getimage-simple.php3?imageID=18 Which is generated by: mysql_connect($DBHOST, $DBUSER, $DBPASS); mysql_select_db($DATABASE); $resultset = mysql_query($query); $query = "SELECT image FROM ztpv_images WHERE imageID = $imageID"; $resultset = mysql_query($query); print(stripslashes(base64_decode(mysql_result($resultset, 0, "Image")))); So I couldn't either view the file here.. or within a <SRC="">. See: http://pgs.ca/WLP/profiles/test.html Also thanks for providing the direct URL for :>>Rasmus' classic Photo Album is still online with source code.
The google reference was a bit indirect (but it got to the same place too). Thanks Richard for this. Although I did have problems actually viewing the script. MikeGoogle: "Rasmus Lerdorf" and "Photo Album"
-- Mike Gifford, OpenConcept Consulting, http://openconcept.ca Offering everything your organization needs for an effective web site. Regarding Sept 11, http://www.fgcquaker.org/statement091101.html In all things it is better to hope than to despair.Wolfgang von Goethe----- Original Message ----- From: Mike Gifford <mike@openconcept.on.ca> Newsgroups: php.general To: <php-general@lists.php.net> Sent: Tuesday, September 11, 2001 2:45 PM Subject: Uploading Photos to MySQLHello, Has anyone developed another class for uploading images to a MySQLdatabase?I downlaoded upload_db.zip from: http://circle.ch/scripts/ as it was a phplib based and it looks like it should do what is required. However it doesn't seem to be working. Does anyone else have any good pointers to scripts to store jpg/png filesinMySQL using PHP? Thanks. Mike -- Mike Gifford, OpenConcept Consulting, http://openconcept.ca Offering everything your organization needs for an effective web site. Abolish Nuclear Weapons Now!: http://pgs.ca/petition/ In all things it is better to hope than to despair.Wolfgang von Goethe-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net