Help: Uploading .zip to Python CGI

Will Stuyvesant hwlgw at hotmail.com
Sat Dec 6 21:40:43 CET 2003


I am uploading a .zip file to a Python CGI program, using a form on
a HTML page with

    <input name="yourfile" type="file">...

In the Python CGI program I do:

import cgi
fStorage = cgi.FieldStorage()
zipdata = fStorage['yourfile'].value
print "Content-type: text/plain"
print
print len(zipdata)

Now the length of the zipdata is 100, where it should be about
2635...and unzipping it with zipfile of course gives the "not a zip
file" error.

The last part of the data that is received by the CGI script is:

\xf2\xf1!0\xdbS\xa9

and the next one *should* be \x1a

It seems that the .zip data is being truncated, but I don't know where
in my tool chain.


The strange thing is that the Python CGI script *does* work on a
Apache 1.3.27 server at work (unix), but gives the error above when
run on
my laptop with Windows XP and Apache 1.3.27 and also with the Apache
version 2.0.48 I tried later.

Does anybody have a clue what is going on?

Maybe the error is with the Windows version of Apache?  Or is it a
Python problem (the unix server has Python 2.1.1).




More information about the Python-list mailing list