tags:

views:

18

answers:

1

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
The problem is that this method actually called AFTER the image was already uploaded..
bugspy.net
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