Hi,
I am trying to implement a file upload solution using app engine and python. The thing which I am struggling with checking whether there is actually a file attached to the form or not. I am setting the enctype="multipart/form-data" and in principle it works. My python handler looks like this:
fileupload = self.request.POST["content"]
if not fileupload:
return self.error(400)
This works if there is no file attached. However if there is a file attached it gives the following error:
File "D:\eclipse_dev\workspace\test\src\handlers.py", line 351, in post
if not fileupload:
File "C:\Python25\lib\cgi.py", line 633, in __len__
return len(self.keys())
File "C:\Python25\lib\cgi.py", line 609, in keys
raise TypeError, "not indexable"
TypeError: not indexable
How can I safely check that an upload is present before doing anything else in the handler?
Thanks for any help.
Regards, Robin