[Zope] Help on upload images

J Cameron Cooper jccooper@jcameroncooper.com
Sun, 06 Apr 2003 14:27:33 -0500


>
>
>The system is looking for the images in Zope server while the actual image
>for uploading resides in the PC.  How I do "tell" the Zope the location of
>the image file?
>  
>
I can't tell you how to stick a BLOB into Postgres syntax-wise. What I 
can tell you is this:

inserting a file path isn't going to work. The server has no way dealing 
with that.

When you submit a form with an input with type 'file' that file is 
sucked off the client's machine and sent to Zope, which makes it into a 
Python file-appearing object. You can operate on this the same way as 
any Python file object.

To put that data into the database, you must put it into an SQL query, 
and that means dtml-sqlvar statements. When you use sqlvar on a fileish 
object, my guess is that is simply inserts the contents (though I 
haven't checked.) So you can probably just do it like any regular BLOB 
insertion, but sticking a dtml-sqlvar tag where the binary data should 
be. It probably works much like a regular zsql insert. At worst, you 
write a small script to return the fileish object's data and use a 
regular dtml-var on that.

            --jcc