S
S
Sergey Nizhny Novgorod2016-06-16 14:47:58
Django
Sergey Nizhny Novgorod, 2016-06-16 14:47:58

How to limit file upload size in Django?

Hello.
Situation: The
user uploads an avatar through the form on the site, which is stored in the imageFiled field. In my personal account, I already correctly display this picture through easy-thumbnails. However, nothing prevents the client from uploading a giant picture and giving me a memory. Therefore:
1) Either you need to limit the size of the picture that the client can download.
2) Either accept the file, compress it and only then save it. (but again, nothing prevents us from filling up the memory while we take it).
In general, how to be and how best to solve this situation?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
un1t, 2016-06-16
@Terras

The size of the uploaded file can be limited at the nginx level.
client_max_body_size 20m;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question