From: | Joe Conway <mail(at)joeconway(dot)com> |
---|---|
To: | Frank Joerdens <frank(at)joerdens(dot)de> |
Cc: | pgsql-php(at)postgresql(dot)org, adam(at)archi-me-des(dot)de, linuxkurs(at)fas-art(dot)com |
Subject: | Re: How to send bytea data straight to browser (as in pg_loreadall)? |
Date: | 2002-04-01 21:22:05 |
Message-ID: | 3CA8CF7D.9060303@joeconway.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-php |
Frank Joerdens wrote:
> I've played with fgets, fwrite, fputs, fpassthrough, trying to make a
> file pointer on stdout with fopen . . . it appears that I don't
> understand some crucial point about how this works. How do you present
> an image to the browser without actually creating a file for it? The
> built in function pg_loreadall appears to do exactly that. I'd need to
> replicate that functionality for bytea.
>
> Regards, Frank
I've always approached this a bit differently, but in any case, did you
try to use "php://stdout"? If not see:
http://www.php.net/manual/en/function.fopen.php
I usually create one php file to generate the image output, and a second
one which calls the first. E.g. (untested)
---------------------- begin showimgage.php ----------------------
<?PHP
$conn = pg_pconnect("host=192.168.100.70 dbname=bytea_test");
$query = "SELECT img FROM bytea_t where id=" . $_GET["imgid"];
$result = pg_exec($conn, $query);
$image = stripcslashes(pg_result($result, 0, 0));
// send the image
header("content-type: image/gif");
echo $image;
?>
---------------------- showimgage.php ----------------------
The second file would then have a line like:
echo "<img src='showimage.php?imgid=1' border=0>";
Hope this helps,
Joe
From | Date | Subject | |
---|---|---|---|
Next Message | Jean-Christophe FABRE | 2002-04-03 14:47:29 | bytea or large object |
Previous Message | Frank Joerdens | 2002-04-01 19:09:37 | Re: How to send bytea data straight to browser (as in pg_loreadall)? |