Re: JPG Images from database to filename.jpg

From: Date: Fri, 16 Nov 2001 05:55:15 +0000
Subject: Re: JPG Images from database to filename.jpg
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-74821@lists.php.net to get a copy of this message
> Header("Content-type: image/jpeg"); > echo $Images; > > I can't figure out how to create the header. There's lots of examples > of how to do the above, but I have yet to stumble across an example > which allows you to write the header into a file.... You could make a PHP script that generate the picture? Like this: <?php /* Picture file need an ID!! */ $connection = mysql_connect("host", "user", "pwd"); mysql_select_db("dbname"); $query = 'SELECT imagefiled FROM imagetabel WHERE id = '.$id; $result = mysql_query($query); if(mysql_num_rows($result) > 0) { //You got the image header("Content-type: image/jpeg"); $row = mysql_fetch_row($result); echo $row[0]; } else { //No image with that id! } mysql_close($connection); ?> HTML file where the image is: <html> <body> <img src="phpfile.php?id=23" border=0 alt=""> </body> </html> Dont know if you misunderstand you? Regards, Johan

« previous php.general (#74821) next »