Re: Load Image from File to Store in ByteA Field

Поиск
Список
Период
Сортировка
Искать
От
Muhyiddin A.M Hayat
Тема
Re: Load Image from File to Store in ByteA Field
Дата
Msg-id
00be01c3ea38$247b62c0$4f00a8c0@MIDDINKS
Список
Дерево обсуждения
Re: Load Image from File to Store in ByteA Field "Cornelia Boenigk" <poppcorn@cornelia-boenigk.de>
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
> 

В списке pgsql-php по дате отправления
От: Muhyiddin A.M Hayat
Дата:
Сообщение: Table Size
От: scott.marlowe
Дата:
FAQ