[Zope-DB] Help on uploading images to Postgresql

Yves Bastide Yves.Bastide@irisa.fr
Mon, 07 Apr 2003 15:40:20 +0200

* as said previously, you need enctype="multipart/form-data"; otherwise 
your image is not sent to the server, only its name

* don't use lo_import and friends. Declare your field as bytea:
create table photo (
   person_id text not null references personne, -- or something
   comments text,
   pic bytea);

You may also want to add a field for the mime type.

* the binary data must be quoted using psycopg.Binary
insert into photo(person_id, comments, pic)
values (
   <dtml-sqlvar person_id type="string">,
   <dtml-sqlvar comments type="string">, -- or '<dtml-var comments 
   <dtml-var quoted_pic>::bytea