[Zope] Uploading photos into an SQL database

Mayers, Philip J p.mayers@ic.ac.uk
Fri, 22 Jun 2001 12:46:30 +0100


...Never mind the why. The photo data (small - 80kb JPEGs) has to go into
the PostgresSQL database. I'm using something like this:

SQL_add_photo:

insert into photo (id,data) values ( <dtml-sqlvar id type=int>, <dtml-sqlvar
data type=string>)

add_photo:

container.SQL_add_photo(id,file.read())

index_html:

<form action="add_photo" method="post" enctype="multipart/form-data">
<input type="text" name="id">
<input type="file" name="file">
<input type="submit" name="Add">
</form>

But I get:

Error Type: Programming Error
Error Value: ERROR: Unterminated quoted string insert into photo (id,data)
values ( 17, '<y-umlaut><a accent>

Any ideas? Apart from base64 encoding, that is...

Regards,
Phil

+----------------------------------+
| Phil Mayers, Network Support     |
| Centre for Computing Services    |
| Imperial College                 |
+----------------------------------+