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)
{
echo "An error occured.\n";
exit;
}
else
{
header('Content-type: image/jpeg');
echo pg_unescape_bytea($raw);
}
// Closing connection
pg_close($dbconn);
?>
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php