Re: upload an image and store it in mysql
| From: | Five | 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:
jw4ëÜqÈHæQI'Úeã@D[A\Á `Ñ*[#j ¥q6Ñ]Q.b
â¶(Y:9£-"Òª(K\¯'½È ÛÃEbXÊê£W(Ìe
9ƹpã´EXaâÑlÑ˵m8=±{ãx´fî ©ÜÎ Lãùy§ùeñ©±(£â5
¢µPP3aª Ãço XÓD ~ûüJ¢
ÜVиܶF&·7´© cæ[3bä±C°&EôÐî