Re: OID output problems

From: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
To: surfer girl <gidget(at)getitgear(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: OID output problems
Date: 2000-05-02 21:07:56
Message-ID: Pine.LNX.3.96.1000502230113.28206A-100000@ara.zf.jcu.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Tue, 2 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.
>
> The inputting seems to be going fine - well, it seems to be fine, since I can't test it because it's the output I'm stuck on.
>
> What I've got so far is:
>
> <?PHP
> Header("Content-type: image/gif");
> (DATABASE CONNECT STUFF HERE)
> pg_exec ($conn, "BEGIN");
> $result = pg_Exec($conn, "SELECT file FROM file WHERE key_fileid = '7'");
> $oid = pg_Result($result, 0, "file");
> $handle = pg_loopen($conn, $oid, "r");
> pg_loreadall($handle);
> pg_exec ($conn, "COMMIT");
> ?>
>
> What this does is print up a broken image in the browser.

I known this proble. You are probably right. A problem (IMHO) is in PHP.

Try use insdead pg_readall() this code with pg_loread():

$data = pg_loread($handle, 5000000 /* or a exactly size */);
echo $data;


Karel

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Steve Wolfe 2000-05-02 21:12:02 Re: RE: One last thing... psql and readline
Previous Message surfer girl 2000-05-02 21:00:15 OID output problems