pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedhtml display images without intermediate file
2+ messages / 2 participants
[nested] [flat]
* html display images without intermediate file
@ 2014-04-09 16:01 paul@mybofy.net
2014-04-09 17:17 ` Re: html display images without intermediate file Vincent <vinny@xs4all.nl>
0 siblings, 1 reply; 2+ messages in thread
From: paul@mybofy.net @ 2014-04-09 16:01 UTC (permalink / raw)
To: pgsql-php
Bonjour
code working :
$link = pg_Connect("host=localhost dbname=... user=... password='...'");
$res = pg_query($link, "select miniature from photo ");
$numrows = pg_numrows($res);
for($ri = 0; $ri < $numrows; $ri++) {
$row = pg_fetch_array($res, $ri);
$img = pg_unescape_bytea($row['miniature']);
$fln = "toto".$ri.".jpeg";
file_put_contents($fln, $img);
echo "<img src='".$fln."'/>";
}
How to do without the intermediate file $fln ?
Merci
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: html display images without intermediate file
2014-04-09 16:01 html display images without intermediate file paul@mybofy.net
@ 2014-04-09 17:17 ` Vincent <vinny@xs4all.nl>
0 siblings, 0 replies; 2+ messages in thread
From: Vincent @ 2014-04-09 17:17 UTC (permalink / raw)
To: pgsql-php
On 09-04-14 18:01, paul@mybofy.net wrote:
>
> Bonjour
> code working :
> $link = pg_Connect("host=localhost dbname=... user=... password='...'");
> $res = pg_query($link, "select miniature from photo ");
> $numrows = pg_numrows($res);
> for($ri = 0; $ri < $numrows; $ri++) {
> $row = pg_fetch_array($res, $ri);
> $img = pg_unescape_bytea($row['miniature']);
> $fln = "toto".$ri.".jpeg";
> file_put_contents($fln, $img);
> echo "<img src='".$fln."'/>";
> }
> How to do without the intermediate file $fln ?
> Merci
The src in the img tag should point to a script that fetches the image,
see header() in the PHP manual.
But you probably should not do that, because it is very slow and loads
the database up with tasks that it should not do.
Keep images as files on disk, that is *much* faster.
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2014-04-09 17:17 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-04-09 16:01 html display images without intermediate file paul@mybofy.net
2014-04-09 17:17 ` Vincent <vinny@xs4all.nl>
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