pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Vincent <vinny@xs4all.nl>
To: pgsql-php@postgresql.org
Subject: Re: html display images without intermediate file
Date: Wed, 09 Apr 2014 19:17:24 +0200
Message-ID: <534580A4.1060603@xs4all.nl> (raw)
In-Reply-To: <007D0FCB-F62D-4485-8A24-BEED4102A912@mybofy.net>
References: <007D0FCB-F62D-4485-8A24-BEED4102A912@mybofy.net>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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.

view thread (2+ messages)

Message-ID: <534580A4.1060603@xs4all.nl>
Permalink:  ../534580A4.1060603@xs4all.nl/
Also on:    postgresql.org/message-id/534580A4.1060603@xs4all.nl

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: vinny@xs4all.nl
  Subject: Re: html display images without intermediate file
  In-Reply-To: <534580A4.1060603@xs4all.nl>
  References: <007D0FCB-F62D-4485-8A24-BEED4102A912@mybofy.net> <534580A4.1060603@xs4all.nl>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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