cgi lib question
Gandalf
gandalf at geochemsource.com
Thu Mar 18 09:50:14 EST 2004
Hi All!
I'm using IIS with Python (as an ActiveScript language). I would like to
upload files with multipart/form-data.
Here is my code:
length = Request.TotalBytes
data = Request.BinaryRead(length)
f = cStringIO.StringIO(data[0])
values = cgi.parse_multipart(f,header)
And the HTML code:
<form name="frmSend" method="POST" enctype="multipart/form-data"
action="upload_test.asp"">
File 1: <input name=attach1 type=file size=35><br>
File 2: <input name=attach2 type=file size=35><br>
File 3: <input name=attach3 type=file size=35><br>
File 4: <input name=attach4 type=file size=35><br>
<br>
<input style="margin-top:4" type=submit value="Upload">
</form>
It works well when I upload text files (Content type:text/plain).
However, it raises an exception when I try to upload a binary file
(octet-stream).
Here is the message:
Python ActiveX Scripting Engine (0x80020009)
Traceback (most recent call last): File "<Script Block >", line 26, in ?
values = cgi.parse_multipart(f,header) File "D:\Python23\lib\cgi.py",
line 250, in parse_multipart raise ValueError, ('Invalid boundary in
multipart form: %s' ValueError: Invalid boundary in multipart form: ''
Is it a bug in the cgi module? What did I wrong? Thanks.
G
More information about the Python-list
mailing list