next time consider recommending pillow instead of PIL
https://github.com/python-imaging/Pillow
https://pypi.python.org/pypi/Pillow/2.0.0


On Tue, Mar 26, 2013 at 4:30 AM, Nikolas Stevenson-Molnar <
[email protected]> wrote:

> I think you can get at a file's size with the 'size' attribute (in
> bytes). Conceivably you could stick it inside a "clean" method for your
> form and do it that way.
>
> class MyForm(forms.Form):
>     ...
>     def clean_image(self):
>         image = self.cleaned_data['image']
>         if image.size > 1024*1024: //1MB
>             raise forms.ValidationError("Images are limited to 1MB")
>         return image
>
> Alternatively, if you have PIL installed, you can use it to look at the
> image dimensions and cap enforce restrictions there (or simply rescale
> to the maximum). http://www.pythonware.com/products/pil/
>
> _Nik
>
> On 3/25/2013 7:24 PM, Shawn Milochik wrote:
> > It's easy to do it by file size in your server config. For example, in
> > nginx or Apache. You shouldn't have to set it in Django, and I don't
> > believe Django provides any ability to cap it.
> >
> > https://docs.djangoproject.com/en/dev/topics/http/file-uploads/
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to