Setting a Limit to the Maximum Size of an Upload

Joey C. joeyjwc at gmail.com
Mon Oct 24 05:52:33 EDT 2005


Hello,
I'm designing a small "briefcase" program that will allow me to quickly
upload, download, and delete files in a briefcase.  The only real
things that I have left to do are to design a method for checking if
the file exists, preventing it from overwriting files from other
directories, and setting a user-configurable maximum limit on the
file's size.  The former two, I can handle by myself with no problem.
However, the I'm having a little trouble with.

thefile = params["upfile.file"]
if os.path.getsize(thefile) <= conf["upmax"]:
    print "File Size Okay."     #Add Functions Later...
else:
    print "File Too Large."     #Here, too.

CGItb reported the following error:
TypeError: coercing to Unicode: need string or buffer, instance found
      args = ('coercing to Unicode: need string or buffer, instance
found',)

This seems like an incredibly simple problem, but I just can't seem to
wrap my mind around it.  Thank you for your help.




More information about the Python-list mailing list