Re: Setting a Limit to the Maximum Size of an Upload

2005-10-27 Thread Joey C.
Yes, I see that now. I tried your method and it seemed to work fine until I tried printing the filesize out. def checkfilesize(thefile): # Check the Size of the File global filesize thefile.seek(0,2) filesize = thefile.tell() thefile.seek(0) print filesize print conf[upmax]

Re: Setting a Limit to the Maximum Size of an Upload

2005-10-25 Thread Fredrik Lundh
Joey C. wrote: Here is a basic overview of the variables included there. params = cgi.FieldStorage() I accidentally made a mistake when typing what the thefile variable is. thefile = params[upfile].file upfile is the CGI field that contains the file that I'm uploading. As you can see, the

Re: Setting a Limit to the Maximum Size of an Upload

2005-10-25 Thread Joey C.
I'm afraid on my interpreter, this works. if os.path.getsize(C:\\Documents and Settings\\Joey\\Desktop\\file.txt) = 1000: print = 1000. = 1000. No problems there, as you can see. -- http://mail.python.org/mailman/listinfo/python-list

Re: Setting a Limit to the Maximum Size of an Upload

2005-10-25 Thread Fredrik Lundh
Joey C. wrote: I'm afraid on my interpreter, this works. if os.path.getsize(C:\\Documents and Settings\\Joey\\Desktop\\file.txt) = 1000: print = 1000. = 1000. No problems there, as you can see. I'm not sure if you replied to my post, but what I tried to say is that

Re: Setting a Limit to the Maximum Size of an Upload

2005-10-25 Thread Joey C.
Oh, I'm sorry, I didn't understand what you meant at first. Then I read your reply over again and noticed that you said that the problem lied in os.path.getsize() when I tried to run it on the contents of an open file. I'll try the method you outlined now. --

Setting a Limit to the Maximum Size of an Upload

2005-10-24 Thread Joey C.
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

Re: Setting a Limit to the Maximum Size of an Upload

2005-10-24 Thread Fredrik Lundh
Joey C. wrote: 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

Re: Setting a Limit to the Maximum Size of an Upload

2005-10-24 Thread Joey C.
Here is a basic overview of the variables included there. params = cgi.FieldStorage() I accidentally made a mistake when typing what the thefile variable is. thefile = params[upfile].file upfile is the CGI field that contains the file that I'm uploading. As you can see, the if statement just