Re: upload an image and store it in mysql

From: Date: Thu, 15 Jul 2004 04:21:01 +0000
Subject: Re: upload an image and store it in mysql
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-190559@lists.php.net to get a copy of this message
"John W. Holmes" <holmes072000@charter.net> wrote in message news:40F5BC1F.80907@charter.net... > Five wrote: > > I have php code that takes text input from a webpage and and stores it in a mysql data > > base. > > I tried uploading small images (jpg) using basically the same syntax but they don't > > make it into the data base. > > Does anyone know of a simple tutorial that shows how to do this? > > although I'm against storing files in databases... > > $file = > > mysql_real_escape_string(file_get_contents($_FILES['yourfile']['tmp_name'])); > $query = "INSERT INTO yourtable (imgdata) VALUES ('$file')"; > > -- > ---John Holmes... > > Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ > > php|architect: The Magazine for PHP Professionals – www.phparch.com Thanks, that seems to work. Although trying to retrieve them and show them in a browser shows characters / symbols instead. This kind of stuff: jw4ëÜ­qÈHæQI'‰Úe“ã“@D[‡A\Á­ `Ñ*[#‰j ¥q6є]Q.b Œâ¶(YŒ:9£-"Òª(K\¯'½È ŽÛÃEbXÊê£W(Ìe 9Æ›¹pã´EXŽaâÑlÑ˵m8=˜±{ãx´fî ©ÜÎ Lãùy§ùeñ©±(£Žâ5Œ ¢µPP€‹3›aª —Ãç‰o XŠÓD ~ûüJ¢ ÜVиܶF&·7´š© cæ[3b䱄C°&EôÐî 

« previous php.general (#190559) next »