Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WXw7w-00013O-ST for pgsql-php@arkaria.postgresql.org; Wed, 09 Apr 2014 17:17:33 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WXw7w-0006tz-7Y for pgsql-php@arkaria.postgresql.org; Wed, 09 Apr 2014 17:17:32 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WXw7v-0006tp-Cj for pgsql-php@postgresql.org; Wed, 09 Apr 2014 17:17:31 +0000 Received: from smtp-vbr13.xs4all.nl ([194.109.24.33]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WXw7s-0001dj-8V for pgsql-php@postgresql.org; Wed, 09 Apr 2014 17:17:30 +0000 Received: from [10.0.0.12] (dhcp-077-249-229-020.chello.nl [77.249.229.20]) (authenticated bits=0) by smtp-vbr13.xs4all.nl (8.13.8/8.13.8) with ESMTP id s39HHOaC038636 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Wed, 9 Apr 2014 19:17:25 +0200 (CEST) (envelope-from vinny@xs4all.nl) Message-ID: <534580A4.1060603@xs4all.nl> Date: Wed, 09 Apr 2014 19:17:24 +0200 From: Vincent User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: pgsql-php@postgresql.org Subject: Re: html display images without intermediate file References: <007D0FCB-F62D-4485-8A24-BEED4102A912@mybofy.net> In-Reply-To: <007D0FCB-F62D-4485-8A24-BEED4102A912@mybofy.net> Content-Type: multipart/alternative; boundary="------------040003050602020802030706" X-Virus-Scanned: by XS4ALL Virus Scanner X-Pg-Spam-Score: 0.5 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-php Precedence: bulk Sender: pgsql-php-owner@postgresql.org This is a multi-part message in MIME format. --------------040003050602020802030706 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 ""; > } > 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. --------------040003050602020802030706 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
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.
--------------040003050602020802030706--