Help: Uploading .zip to Python CGI

jmdeschamps jmdeschamps at cvm.qc.ca
Sun Dec 7 21:55:38 CET 2003


hwlgw at hotmail.com (Will Stuyvesant) wrote in message news:<cb035744.0312061240.76b902f5 at posting.google.com>...
> 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.
> 
...
> 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).

Had a similare problem with *.jpg uploads

uploading files with a shebang such as:
#! c:/python23/python -u
reolved it for me
the -u part telling Windows to get data "unbuffered", so I read somewhere...

Good weekend,

JM




More information about the Python-list mailing list