How to check if a file is empty avoid reading the whole file in a submit form?
<p>I am using django, and in a web submit form, I want to check if a uploading file is empty, but avoid uploading or reading the whole file to get the file size, because it might be huge and take time to calculate.</p>

<pre><code>import os
&gt;&gt;&gt; os.stat("file").st_size == 0
True
</code></pre>

<p>by using this code you can check file is empty or not </p>

python django web