From middink@indo.net.id Mon Feb 2 04:57:19 2004 X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B92F3D1D286 for ; Mon, 2 Feb 2004 04:57:19 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 31406-07 for ; Mon, 2 Feb 2004 00:57:15 -0400 (AST) Received: from smtp-1.indo.net.id (smtp-1.indo.net.id [202.159.32.91]) by svr1.postgresql.org (Postfix) with SMTP id DB7FBD1CAC7 for ; Mon, 2 Feb 2004 00:57:11 -0400 (AST) Received: (qmail 8187 invoked from network); 2 Feb 2004 11:57:07 +0700 Received: from smtp.indo.net.id (202.159.32.81) by smtp-1.indo.net.id with SMTP; 2 Feb 2004 11:57:07 +0700 Received: (qmail 7382 invoked from network); 2 Feb 2004 11:57:01 +0700 Received: from unknown (HELO smtp.surabaya.indo.net.id) (202.159.51.117) by smtp.indo.net.id with SMTP; 2 Feb 2004 11:57:01 +0700 Received: from smtp [202.159.51.117] by smtp.surabaya.indo.net.id (SMTPD32-7.10) id ADCAC7006C; Mon, 02 Feb 2004 11:10:50 +0700 Received: FROM MIDDINKS BY smtp ; Mon Feb 02 11:10:48 2004 +0700 Message-ID: <003c01c3e948$ee2bc970$4f00a8c0@MIDDINKS> From: "Muhyiddin A.M Hayat" To: Subject: Load Image from File to Store in ByteA Field Date: Mon, 2 Feb 2004 12:55:27 +0800 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0037_01C3E98B.D4C9B260" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=BAYES_50, HTML_60_70, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200402/6 X-Sequence-Number: 2554 This is a multi-part message in MIME format. ------=_NextPart_000_0037_01C3E98B.D4C9B260 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable How to Load Image from File to Store in ByteA Field? ------=_NextPart_000_0037_01C3E98B.D4C9B260 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
How to Load Image from File to Store in By= teA=20 Field?
 
------=_NextPart_000_0037_01C3E98B.D4C9B260-- From poppcorn@cornelia-boenigk.de Mon Feb 2 19:10:06 2004 X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E3847D1D2DF for ; Mon, 2 Feb 2004 19:10:06 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 42536-06 for ; Mon, 2 Feb 2004 15:10:00 -0400 (AST) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.183]) by svr1.postgresql.org (Postfix) with ESMTP id 478AAD1D2A0 for ; Mon, 2 Feb 2004 15:09:58 -0400 (AST) Received: from [212.227.126.162] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1AnjRv-0002ip-00; Mon, 02 Feb 2004 20:09:35 +0100 Received: from [80.145.75.194] (helo=zwerg2000) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1AnjRv-0000bP-00; Mon, 02 Feb 2004 20:09:35 +0100 Message-ID: <00c101c3e9c0$79373640$0201a8c0@zwerg2000> From: "Cornelia Boenigk" To: "Muhyiddin A.M Hayat" , "PGSQL+PHP" References: <003c01c3e948$ee2bc970$4f00a8c0@MIDDINKS> Subject: Re: Load Image from File to Store in ByteA Field Date: Mon, 2 Feb 2004 20:12:08 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:3729ab4bb5525dad81693a55f34190d5 X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=BAYES_44, RCVD_IN_NJABL, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200402/7 X-Sequence-Number: 2555 Hi > How to Load Image from File to Store in ByteA Field? This is the way I store images with PHP. The column bild has the datatype bytea. function esc_bytea($imagedata) { $finde = array(chr(92), chr(0), chr(39)); $ersetze = array('\\\134', '\\\000', '\\\047'); $esc = str_replace($finde[0], $ersetze[0], $imagedata); $esc = str_replace($finde[1], $ersetze[1], $esc); $esc = str_replace($finde[2], $ersetze[2], $esc); return $esc; } $fp = fopen($imagefile,"r"); $contents = fread($fp, filesize($imagefile)); fclose($fp); $esc_daten = esc_bytea($contents); $sql = "INSERT INTO byteatest (bild, name, size, typ, htmlstr) "; $sql .= "values ('$esc_daten', '$name', $size, '$typ', '$htmlstr');"; $res = @pg_exec($sql) or die ("Fehler bei der Datenbankabfrage."); Regards Conni From pntil@shentel.net Mon Feb 2 23:49:27 2004 X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 04688D1B45B for ; Mon, 2 Feb 2004 23:49:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 52191-06 for ; Mon, 2 Feb 2004 19:49:26 -0400 (AST) Received: from seahorse.shentel.net (seahorse.shentel.net [204.111.11.44]) by svr1.postgresql.org (Postfix) with ESMTP id 14DF4D1C915 for ; Mon, 2 Feb 2004 19:49:23 -0400 (AST) Received: from shentel.net (ha96s373.d.shentel.net [204.111.97.117]) by seahorse.shentel.net (8.11.7/8.11.7) with ESMTP id i12NnH429746 for ; Mon, 2 Feb 2004 18:49:17 -0500 Message-ID: <401EE1F0.2030106@shentel.net> Date: Mon, 02 Feb 2004 18:49:04 -0500 From: Paul & Natalie T User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-php@postgresql.org Subject: Re: Load Image from File to Store in ByteA Field References: <003c01c3e948$ee2bc970$4f00a8c0@MIDDINKS> <00c101c3e9c0$79373640$0201a8c0@zwerg2000> In-Reply-To: <00c101c3e9c0$79373640$0201a8c0@zwerg2000> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/9 X-Sequence-Number: 2557 Any modern version of PHP which has pg_ specific functions can do it like this: $string = pg_escape_bytea(file_get_contents($filename)); pg_query("INSERT INTO TABLE pictures (picture_bytea) VALUES ('$string');"); I prefer to use pg_escape() rather than code my own escape. Paul >Hi > > > >>How to Load Image from File to Store in ByteA Field? >> >> >This is the way I store images with PHP. The column bild has the >datatype bytea. > >function esc_bytea($imagedata) { > $finde = array(chr(92), chr(0), chr(39)); > $ersetze = array('\\\134', '\\\000', '\\\047'); > $esc = str_replace($finde[0], $ersetze[0], $imagedata); > $esc = str_replace($finde[1], $ersetze[1], $esc); > $esc = str_replace($finde[2], $ersetze[2], $esc); > return $esc; >} > > $fp = fopen($imagefile,"r"); > $contents = fread($fp, filesize($imagefile)); > fclose($fp); > $esc_daten = esc_bytea($contents); > > $sql = "INSERT INTO byteatest (bild, name, size, typ, htmlstr) "; > $sql .= "values ('$esc_daten', '$name', $size, '$typ', >'$htmlstr');"; > $res = @pg_exec($sql) or die ("Fehler bei der >Datenbankabfrage."); > >Regards >Conni > > >---------------------------(end of broadcast)--------------------------- >TIP 8: explain analyze is your friend > > > > From poppcorn@cornelia-boenigk.de Tue Feb 3 01:08:21 2004 X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id ACD5FD1C512 for ; Tue, 3 Feb 2004 01:08:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 79243-01 for ; Mon, 2 Feb 2004 21:08:18 -0400 (AST) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.189]) by svr1.postgresql.org (Postfix) with ESMTP id 4F557D1BCA7 for ; Mon, 2 Feb 2004 21:08:14 -0400 (AST) Received: from [212.227.126.160] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1Anp2z-0007XN-00; Tue, 03 Feb 2004 02:08:13 +0100 Received: from [80.145.75.194] (helo=zwerg2000) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1Anp2z-0006jo-00; Tue, 03 Feb 2004 02:08:13 +0100 Message-ID: <00fc01c3e9f2$936f05b0$0201a8c0@zwerg2000> From: "Cornelia Boenigk" To: "Paul & Natalie T" , References: <003c01c3e948$ee2bc970$4f00a8c0@MIDDINKS> <00c101c3e9c0$79373640$0201a8c0@zwerg2000> <401EE1F0.2030106@shentel.net> Subject: Re: Load Image from File to Store in ByteA Field Date: Tue, 3 Feb 2004 02:09:04 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:3729ab4bb5525dad81693a55f34190d5 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/12 X-Sequence-Number: 2560 hi Paul > Any modern version of PHP which has pg_ specific functions can do it > like this: You are 100% right. My application had to run with PHP below 4.2 where pg_escape_bytea() was not yet defined. And it works also with higher PHP versions ;-) Conni From middink@indo.net.id Tue Feb 3 09:50:39 2004 X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 3BC4DD1D313 for ; Tue, 3 Feb 2004 09:50:39 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 32310-09 for ; Tue, 3 Feb 2004 05:50:30 -0400 (AST) Received: from smtp-1.indo.net.id (smtp-1.indo.net.id [202.159.32.91]) by svr1.postgresql.org (Postfix) with SMTP id 8EDBCD1D501 for ; Tue, 3 Feb 2004 05:50:22 -0400 (AST) Received: (qmail 16229 invoked from network); 3 Feb 2004 16:29:32 +0700 Received: from smtp.indo.net.id (202.159.32.81) by smtp-1.indo.net.id with SMTP; 3 Feb 2004 16:29:32 +0700 Received: (qmail 27147 invoked from network); 3 Feb 2004 16:29:31 +0700 Received: from unknown (HELO smtp.surabaya.indo.net.id) (202.159.51.117) by smtp.indo.net.id with SMTP; 3 Feb 2004 16:29:31 +0700 Received: from smtp [202.159.51.117] by smtp.surabaya.indo.net.id (SMTPD32-7.10) id AF1629E00E8; Tue, 03 Feb 2004 15:43:02 +0700 Received: FROM MIDDINKS BY smtp ; Tue Feb 03 15:42:58 2004 +0700 Message-ID: <00be01c3ea38$247b62c0$4f00a8c0@MIDDINKS> From: "Muhyiddin A.M Hayat" To: "Paul & Natalie T" , References: <003c01c3e948$ee2bc970$4f00a8c0@MIDDINKS> <00c101c3e9c0$79373640$0201a8c0@zwerg2000> <401EE1F0.2030106@shentel.net> Subject: Re: Load Image from File to Store in ByteA Field Date: Tue, 3 Feb 2004 17:19:32 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/14 X-Sequence-Number: 2562 How big file size do I stored in ByteA Field. ----- Original Message ----- From: "Paul & Natalie T" To: Sent: Tuesday, February 03, 2004 7:49 AM Subject: Re: [PHP] Load Image from File to Store in ByteA Field > Any modern version of PHP which has pg_ specific functions can do it > like this: > > $string = pg_escape_bytea(file_get_contents($filename)); > pg_query("INSERT INTO TABLE pictures (picture_bytea) VALUES > ('$string');"); > > I prefer to use pg_escape() rather than code my own escape. > > Paul > > >Hi > > > > > > > >>How to Load Image from File to Store in ByteA Field? > >> > >> > >This is the way I store images with PHP. The column bild has the > >datatype bytea. > > > >function esc_bytea($imagedata) { > > $finde = array(chr(92), chr(0), chr(39)); > > $ersetze = array('\\\134', '\\\000', '\\\047'); > > $esc = str_replace($finde[0], $ersetze[0], $imagedata); > > $esc = str_replace($finde[1], $ersetze[1], $esc); > > $esc = str_replace($finde[2], $ersetze[2], $esc); > > return $esc; > >} > > > > $fp = fopen($imagefile,"r"); > > $contents = fread($fp, filesize($imagefile)); > > fclose($fp); > > $esc_daten = esc_bytea($contents); > > > > $sql = "INSERT INTO byteatest (bild, name, size, typ, htmlstr) "; > > $sql .= "values ('$esc_daten', '$name', $size, '$typ', > >'$htmlstr');"; > > $res = @pg_exec($sql) or die ("Fehler bei der > >Datenbankabfrage."); > > > >Regards > >Conni > > > > > >---------------------------(end of broadcast)--------------------------- > >TIP 8: explain analyze is your friend > > > > > > > > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend > From scott.marlowe@ihs.com Tue Feb 3 16:29:10 2004 X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 11E23D1CA90 for ; Tue, 3 Feb 2004 16:29:10 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 99106-09 for ; Tue, 3 Feb 2004 12:29:04 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 953C6D1C9DA for ; Tue, 3 Feb 2004 12:29:03 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i13GPCd1023503; Tue, 3 Feb 2004 09:25:14 -0700 (MST) Date: Tue, 3 Feb 2004 09:21:16 -0700 (MST) From: "scott.marlowe" To: "Muhyiddin A.M Hayat" Cc: Paul & Natalie T , Subject: Re: Load Image from File to Store in ByteA Field In-Reply-To: <00be01c3ea38$247b62c0$4f00a8c0@MIDDINKS> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/15 X-Sequence-Number: 2563 Up to about 1 gig (theoretically 2 gig max but encoding might take up some space.) On Tue, 3 Feb 2004, Muhyiddin A.M Hayat wrote: > How big file size do I stored in ByteA Field. >