[Zope] Re: uploading file with python script (problem with it)
Wang Haifeng
zopezen@263.net
Thu, 15 Mar 2001 22:56:34 +0800
Hi, Hans de Wit,
I think there is something wrong with your form. To upload file, the form should specify "enctype" attr to "multipart/form-data". Like this:
<form action="addFile" method="post" enctype="multipart/form-data">...
Simon Wang
---- Original Message --------
From: "Hans de Wit" <hw@scp.nl> <mailto:hw@scp.nl>
Organization: Sociaal & Cultureel Planbureau
To: zope@zope.org <mailto:zope@zope.org>
Date: Wed, 14 Mar 2001 17:20:06 MET
Reply-to: hw@scp.nl <mailto:hw@scp.nl>
Subject: [Zope] Newbie: uploading file with python script (problem with it)
Hello,
I have a problem uploading files via a form and a python script.
The content of the uploaded file after uploading it is only a string, ie the name of the
file, not the file itself. I followed the guestbook example of the Zopebook.
This is the receiving Python script.
# create a unique file id
id='entry_%d' % len(context.objectIds())
# create the file
afile=context.REQUEST['afilename']
context.manage_addProduct['OFSP'].manage_addFile(id,afile)
***
afilename is a field on the form the "sending" form:
<form action="addFile">
Add file:<input type="file" name="afilename:string" size="30"><br>
<input type="submit" value="upload">
</form>
Thanks for any advice