I have in my model an ImageField, and I am using forms.ModelForm to edit the form. I didn't find a way to make the ModelForm limit the uploaded image file size
A:
Here is some info about it: http://docs.djangoproject.com/en/1.2/topics/http/file-uploads/
Something like this:
#The max size in bytes
MAX_SIZE = 1000
if request.FILES['file'].size > MAX_SIZE:
#Lauch error
Tom
2010-07-16 10:49:06
The problem is that this method actually called AFTER the image was already uploaded..
bugspy.net
2010-07-16 11:21:04
mm, i don't think that it is posible to check the file size before it is uploaded. maybe there is a javascript solution, but i don't think so.(it can be a security risk)
Tom
2010-07-16 11:28:28