I know I need to limit the file upload size on server side, as HTML sent to client side can be easily changed. I am just trying to limit the file size on client side so as to improve user experience for normal users. (Showing server error directly to user is not good) I also know that I can do that with javascript, but if it is possible to do file extension limit with <input type="file" accept="image/*">
(reference), I am just wondering is there is a simple way to limit the size of file to be uploaded.
Asked
Active
Viewed 489 times
-1
-
1so check it with javascript onChange and give the user an error right away. No mechanism using only html would trigger an error so I think that is your only option – Velimir Tchatchevsky Apr 07 '16 at 08:51
-
4possible dublicate of http://stackoverflow.com/questions/3717793/javascript-file-upload-size-validation – Lucas Apr 07 '16 at 08:53
-
try this [here](http://stackoverflow.com/questions/5697605/limit-the-size-of-an-file-upload-html-input/17173301#17173301). I think your question is already answered. – Eio Apr 07 '16 at 08:54
-
1Your post is tagged as "JavaScript" and you say you already know how to do it with JavaScript. Then, what are you asking? Do you want to do it with static HTML? – Álvaro González Apr 07 '16 at 09:18
-
Would be best if static HTML, else better some javascript that can make the happen in one or two lines. – cytsunny Apr 07 '16 at 09:41
1 Answers
0
This is not possible with HTML alone. For checking the file size with JavaScript see JavaScript file upload size validation.

Community
- 1
- 1

Nico Wiedemann
- 174
- 2
- 10