0

I have created upload script and worked great, but I don't know how do I check the size of the file before upload because I want to limited on 10mb per file...

So, mu question is: How do I check the size of the file before upload ?

Thanks...

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Krstevski
0

Something like this?

>>> import os
>>> print os.listdir(".")
['DLLs', 'Doc', 'include', 'Lib', 'libs', 'LICENSE.txt', 'NEWS.txt', 'python.exe', 'pythonw.exe', 'README.txt', 'Scripts', 'tcl', 'Tools', 'unicows.dll', 'w9xpopen.exe']
>>> print os.path.getsize("readme.txt")
56189
>>> print (os.path.getsize("readme.txt")) < 10000000
True
>>>
0

Something like this?

>>> import os
>>> print os.listdir(".")
['DLLs', 'Doc', 'include', 'Lib', 'libs', 'LICENSE.txt', 'NEWS.txt', 'python.exe', 'pythonw.exe', 'README.txt', 'Scripts', 'tcl', 'Tools', 'unicows.dll', 'w9xpopen.exe']
>>> print os.path.getsize("readme.txt")
56189
>>> print (os.path.getsize("readme.txt")) < 10000000
True
>>>

Yes, I know about this, but this is if the file is in my computer.
My script is to enable fellows to upload files to me (I'm the server) and now I want to limited the upload on 10mb per file.

I tried with os.path.getsize(os.path.basename(fileitem.filename)) where "fileitem" is the uploaded file but I got the error "No such file or directory"...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.