On Tue, 02 May 2000, surfer girl wrote:
> Hello,
>
> I am trying to write a program that will input and output images from a Postgres database using PHP.
I made a very simple display image routine as follows:
-------------------------------------------------------------------------------
<?php
/*
Takes arg: imageid=oid of image
*/
$conn = pg_pconnect("user=username dbname=databasename");
pg_exec($conn, "begin");
@ $fd = pg_loopen($conn, $imageid, "r");
if($fd) {
$hdr = pg_loread($fd, 4);
switch($hdr) {
case "\xFF\xD8\xFF\xE0":
Header( "Content-type: image/jpeg" );
break;
case "GIF8":
Header( "Content-type: image/gif" );
break;
case "\x89PNG":
Header( "Content-type: image/png" );
break;
}
echo $hdr;
pg_loreadall($fd);
pg_exec($conn, "end");
}
else {
echo "Query rejected.";
}
pg_close($conn);
?>
-------------------------------------------------------------------------------
--
Robert B. Easter
reaster@comptechnews.com