views:

448

answers:

2

I have a form in my django app where users can upload files.
How can i set a limit to the uploaded file size so that if a user uploads a file larger than my limit the form won't be valid and it will throw an error?

+2  A: 

Take a look at this snippet: http://www.djangosnippets.org/snippets/1303/

ign
+2  A: 

I believe that django form receives file only after it was uploaded completely.That's why if somebody uploads 2Gb file, you're much better off with web-server checking for size on-the-fly.

See this mail thread for more info.

Dmitry Shevchenko
I agree with you on this but in my case i need the limit to be in Django.
daniels