pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
PHP & Large Object
3+ messages / 3 participants
[nested] [flat]

* PHP & Large Object
@ 2000-09-19 16:22  Enrico Comini <algobit@algobit.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Enrico Comini @ 2000-09-19 16:22 UTC (permalink / raw)
  To: pgsql-interfaces

Hi, 
I' m a newbie with BLOBS.
I have pg-database with images in large object.
I read (with php) the blob but how to see this image ?

.......
pg_exec ($conn, "begin");
    $handle=pg_loopen($conn,68129,"r");
    $img=pg_loreadall($handle);
    pg_loclose($handle);
pg_exec ($conn, "end"); 

echo "<img src=\"$img\" border=0>";

So i see only the blob like a sequence of chars

Thanks,
                Enrico

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: PHP & Large Object
@ 2000-09-20 00:19  Vic <vic@dcc.dp.ua>
  parent: Enrico Comini <algobit@algobit.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Vic @ 2000-09-20 00:19 UTC (permalink / raw)
  To: algobit@algobit.com; +Cc: pgsql-interfaces

 Hi  Enrico!
   I try  many times this  sample with  one result  -  image  was
fill  browser   as
  "sequence of  chars"  -  i see "dirty screen".  I  start  from
Postgres 6.5.3 and 1.3.6 with PHP 3.0.17,
but  in  other versions - systems i get a same result .

And   in febrary  this year  I  found in   one conf   sample   --- it
work  in  my  intranet.
  Try it.  I think   this trouble must be fixsed  and sample  added in
FAQ :-) )
>----------------------------------------------------------------------------------------------------------------------------------

FILE "image.php3"
<?
$db=pg_connect( "dbname=storage host=localhost user=pvic password=1");
$result=pg_exec( "select image from alldoc where n=$id");
$array=pg_fetch_array($result,0);
$oid=$array["image"];
header( "content-type: image/jpeg");
/* O   this  proc descr i  don't found in   any  doc  but i sure  -- it
pump to browser  type of  BLOB  */
if($oid) {
    pg_exec( "begin");
    $handle=pg_loopen($db,$oid, "r");
    if($handle){
        pg_loreadall($handle);
    }
    pg_loclose($handle);
    pg_exec($db, "commit");
    pg_exec($db, "end");
}
?>
>----------------------------------------------------------------------------------------------------------------------------------

FILE "ti.htm"
<HTML>
<BODY>
 <img src="image.php3?id=3">
</BODY>
</HTML>
>----------------------------------------------------------------------------------------------------------------------------------

Bye.


          Vic








^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: PHP & Large Object
@ 2000-09-20 04:20  Tom Samplonius <tom@sdf.com>
  parent: Enrico Comini <algobit@algobit.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Samplonius @ 2000-09-20 04:20 UTC (permalink / raw)
  To: Enrico Comini <algobit@algobit.com>; +Cc: pgsql-interfaces


On Tue, 19 Sep 2000, Enrico Comini wrote:

> echo "<img src=\"$img\" border=0>";
> 
> So i see only the blob like a sequence of chars


  You must output a "Content-Type" header as appropriate for the type of
file you are sending out.

Tom




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2000-09-20 04:20 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-09-19 16:22 PHP & Large Object Enrico Comini <algobit@algobit.com>
2000-09-20 00:19 ` Vic <vic@dcc.dp.ua>
2000-09-20 04:20 ` Tom Samplonius <tom@sdf.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox