Re: Writing a GIF/JPG Image

From: Date: Sat, 29 Jun 2002 01:23:57 +0000
Subject: Re: Writing a GIF/JPG Image
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-104449@lists.php.net to get a copy of this message
OK, i made this image.php file: ------------start--------------- <?php $theFile = ""; $fcontents = file ('Logo.gif'); while (list ($line_num, $line) = each ($fcontents)) { $theFile .= $line."\n"; } echo $theFile; ?> -------------end----------------- and I have an html file that does <img src="image.php"> but it just prints out a red box with an X, as if image is broken. I know the image is getting read in because I can echo it and its a bunch of garble, just like the jpg is if I open it up in notepad. Any idead? Thanks, Brandon "Rasmus Lerdorf" <rasmus@php.net> wrote in message news:Pine.LNX.4.44.0206281705180.2929-100000@www.lerdorf.com... > You wouldn't. You would write a script like fetch_image.php in which you > would do the mysql_query() and simply echo out the image data. Then in > your main HTML file you would use: > > <img src="fetch_image.php"> > > You can pass information to this script either via GET-method args. eg. > > <img src="fetch_image.php?id=123"> > > Or cooler would be to do an Apache ForceType to the PHP mime type on a > file named "images" in your doc_root and put the fetch image code into > thise images file. Then use: > > <img src="/images/123.jpg"> > > And in your "images" script you would pick the image name out of > $PATH_INFO and do the appropriate mysql query. > > -Rasmus > > On Fri, 28 Jun 2002, Brandon wrote: > > > I would like to store a jpg/gif image in a MySQL database (as a BLOB type I > > guess ;p), how would I output that into an <img src=""> in php? > > > > Thanks in advance, > > brandon > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > >

« previous php.general (#104449) next »