[Zope] File Upload via python
Jonathan Bryant
jonathanbryant@hotmail.com
Thu, 21 Feb 2002 20:51:47
Hi all,
I've been playing around with Zope for several days and really like it. I'm
amazed at how simple so many things that take alot of effort in php, asp
etc. are amazingly simple in Zope. One of those things is file upload, which
works but still puzzles me.
I have a form in a dtml method that looks like this:
<table>
<form method="post" action="testAction" enctype="multi-part/form-data">
<tr><td><strong>FileTitle</strong></td><td><input type="text"
name="item_title" maxlength="30"></td></tr>
<tr><td><strong>Select File</strong></td><td><input type="file"
name="item"></td></tr>
<tr><td align=center colspan=2><input type="submit" Value="Add
File"></td></tr>
</form>
</table>
I figured out that using a python script I can add the file just by
referencing it's name from the form, which is incredibly cool:
context.manage_addProduct['OFSP'].manage_addFile('newFile', item_title,
item)
What I'd like to do is easily grab the filename:
context.manage_addProduct['OFSP'].manage_addFile(item.filename, item_title,
item)
My question is, how do I get the filename or headers? I'm guessing that when
I reference 'item' I'm getting a FileUpload object. What confuses me is that
I can't reference item.filename or item.headers['Content-Type']. I've also
tried using REQUEST['item'].filename like I've seen in several examples.
What am I doing wrong here?
Thanks in advance,
Jonathan Bryant
jonathanbryant@hotmail.com
_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx