I am trying to find that does HTML provide any option in <input type='file' />
to set the minimum and maximum size of file being uploaded.
Asked
Active
Viewed 1,144 times
1
-
A *minimum* file size seems odd to enforce; how can you know the smallest, most optimised possible encoding of your data beforehand? – deceze Jan 28 '16 at 12:03
-
@deceze I just want my form not to upload a file of size 0 bytes – Gardezi Jan 28 '16 at 12:17
-
Since there's no way you can ultimately prevent that, you need to handle that case on the server anyway; and since there's no real harm done (contrary to *too large* files), I don't see the need for it. – deceze Jan 28 '16 at 12:49
1 Answers
1
Yes it does. But theis attribute is for the server side SOFT impose of the limit.
<input type="hidden" name="MAX_FILE_SIZE" value="1024" />
The value is in bytes.
You should use HTML File API to restrain size of the uploads. That is the preferred way.

Charlie
- 22,886
- 11
- 59
- 90
-
How can I do it for the minimum value.like No file size should be less then 1 byte – Gardezi Jan 28 '16 at 11:14
-
1[`MAX_FILE_SIZE` doesn't do anything *in HTML*.](http://stackoverflow.com/q/1381364/476) – deceze Jan 28 '16 at 11:59
-
-
As @deceze has mentioned, browser doesn't do anything for this attribute. It really is for your PHP script to impose a SOFT limit. You can use your own attribute MIN_FILE_SIZE and consider that in your PHP. HTML File API is the real deal.Answer updated. – Charlie Jan 28 '16 at 14:52