[Zope] FileUpload, MySQL, Zope ZSQL problem

Michael Joseph michael at jamwarehouse.com
Wed Jan 21 10:02:57 EST 2004


Hi,

A quick look at the source (Zope/lib/python/Zpublisher/HTTPRequest.py)
suggests that you should be accessing the filename attribute of the
FileUpload instance to get the location of the uploaded file ie. something
like:
<dtml-var expr=picture1.filename>
You can then read the contents of the file and do your insert.

Also, the docstring says:
File upload objects can be used just like files.
So presumably you can access the file data by read() ing from picture1
directly.

HTH
michael 

> -----Original Message-----
> From: zope-bounces at zope.org [mailto:zope-bounces at zope.org] On 
> Behalf Of Quince Gibson
> Sent: Wednesday, January 21, 2004 4:37 PM
> To: zope at zope.org
> Cc: us3media at aol.com
> Subject: [Zope] FileUpload, MySQL, Zope ZSQL problem
> 
> Tried finding an answer to this question but I can't.  I'm 
> trying to upload pictures to a MySQL database with the normal 
> conditions:
> 
> <input type="file" name="picture1">
> enctype="multipart/form-data"
> method="post"
> 
> My ZSQL method has the following DTML:
> <dtml-var expr=picture1.data>
> 
> I've also tried the same thing with dtml-sqlvar using type=string.
> 
> I'm always greeted with the following error whenever I feel 
> I'm going to make a breakthrough:
> 
> FileUpload instance has no attribute 'data'
> 
> removing the ".data" section gives me:
> <ZPublisher.HTTPRequest.FileUpload instance at 0x932c35c> as 
> the entry for that particular field.
> 
> Is it possible??????  Am I trying the impossible??? if not... 
> how can I make it possible to get these pictures into this 
> database. (i'm starting to lose my cool on this computer).
> 
> Thanks for any help.  If it's not possible I guess I'll have 
> to bloat my Object Database rather than my relational databse.
> 
> Quince
> Baltimore, MD.




More information about the Zope mailing list