Thread: html display images without intermediate file
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."'/>";
}
$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
On 09-04-14 18:01, paul@mybofy.net wrote:
The src in the img tag should point to a script that fetches the image, see header() in the PHP manual.Bonjourcode 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
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.