Re: Re: Uploading Photos to MySQL

From: Date: Wed, 12 Sep 2001 16:46:22 +0000
Subject: Re: Re: Uploading Photos to MySQL
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-67062@lists.php.net to get a copy of this message
Mike Gifford wrote: > > 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. I'll send you the code at a separate message, but just look at the tables definitions. There are no blob columns. > > > 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 > Correct! I tried the same but with PDF files. The problem I had was that stripslashes and stripcslashes were not working as the manual said. When I had one \ addslashes() gave me \\ (comfirmed at the DB) but stripslashes() gave me a big nothing striping everything. > > 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)))); Just $this->daten["image"] = base64_encode(fread(fopen($userfile, "r"), filesize($userfile))); The special chars in RFC2045 are from http://www.ietf.org/rfc/rfc2045.txt?number=2045 : tspecials := "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / "\" / <"> "/" / "[" / "]" / "?" / "=" ; Must be in quoted-string, ; to use within parameter values Ok "_" is not there... but anyway you are not going to make searches with " ... like 'something_' ...". > > 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. > >>Google: > >>"Rasmus Lerdorf" and "Photo Album" Have you forgot to add: header ("Content-Type: image/jpeg"); just before the print? If you have the type will be text/plain (or text/html or something). Add it just before anything gets outputed. doing a wget -s I got the replies from your scripts like: Content-Type: text/html Content-Type: image/jpeg ???? No idea about this... Sean C. McCarthy SCI, S.L. (www.sci-spain.com)

« previous php.general (#67062) next »