Re: OID output problems - Mailing list pgsql-general

From Robert B. Easter
Subject Re: OID output problems
Date
Msg-id 00050221364502.00670@comptechnews
Whole thread Raw
In response to OID output problems  (surfer girl <gidget@getitgear.com>)
List pgsql-general
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

pgsql-general by date:

Previous
From: Tom Cook
Date:
Subject: Re: Enumerated data type
Next
From: "Robert B. Easter"
Date:
Subject: Automatically deleting dangling large object references.