Problem with CGI file upload
Shichang Zhao
shichang at icubed.com
Thu Mar 2 14:13:48 EST 2000
I got the following problems with cgi module:
1. when uploading a .gif file, the content is truncated, if the GIF
file to be uploaded is large.
2. For microsoft word document, after I save the uploaded file to a
tmp file in my cgi-bin directory, I try to open the file using microsoft
word. What happens is that the word shows just some weird characters.
The following is the script I am using:
import cgi
form = cgi.FieldStorage()
fileitem = form["UPLOADED_1"]
f = open("tmp.doc", "wb")
while 1:
line = fileitem.file.read()
if line:
f.write(line)
else:
break
f.close()
print "Content-type: text/html"
print
print
print "<pre>Thanks for using this applicaiton.</pre>"
Can someone point out me what is wrong?
Thanks.
More information about the Python-list
mailing list