I uploaded zip folder using file input,but when i check if this zip is valid or not;the result was:is not a valid pkzip file,i don't know what is the specification for valid pkzip. I used this code to check:
form = cgi.FieldStorage()
file_upload = form['file[]']
if zipfile.is_zipfile(file_upload.filename):
print "%s is a valid pkzip file" % file_upload.filename
else:
print "%s is not a valid pkzip file" % file_upload.filename
I don't know why?for example when i upload test.zip,the o/p will be: test.zip is not a valid pkzip file,I need a help.Thanks
zipfile.is_zipfile
takes a path to a file or a file-like object. You're passing it neither, so it fails.
Ask it about file_upload.file
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With