Re: how to retrieve pictures from postgreSQL DB
| From: | tedd | Date: | Sun, 25 Feb 2007 21:09:23 +0000 |
| Subject: | Re: how to retrieve pictures from postgreSQL DB | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-249409@lists.php.net to get a copy of this message | ||
At 8:31 PM +0100 2/25/07, Alain Roger wrote:
Hi, I previously sent email about process how to retrieve and save pictures in postgreSQL DB. Now i know how to save them in DB, however i would like to know how can i retrieve the pictures and display them without knowing the picture extension ? i mean that in my DB i have GIFs, JPGs pictures. 1. My following code display without problem JPEG picture but what about GIF ? 2. How can i display picture without using ==> header('Content-type: image/jpeg'); Because this must be before displaying pictures. 3. what should i do if i want to display several types of pictures in the PHP page ? My code : <?php $dbconn = pg_connect($conn_string) or die('Could not connect: ' . pg_last_error()); $res = pg_query("SELECT * FROM immense.photo where photo_id=20"); $raw = pg_fetch_result($res, 'photo_image'); if (!$res)That's the type of information you should store in your dB along with the image. tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com{ echo "An error occured.\n"; exit;} else {header('Content-type: image/jpeg'); echo pg_unescape_bytea($raw);} // Closing connection pg_close($dbconn); ?>