I want to make validation not to upload a file more than 100 MB in my file up loader widget. Currently I am uploading the file and transferring it on server side and there on server side checking the size. Is there any way so that I can check the file size on client side itself so that it will reduce the time required for file transfer to server side
Asked
Active
Viewed 1,542 times
1
-
1possible duplicate of [javascript file upload size validation](http://stackoverflow.com/questions/3717793/javascript-file-upload-size-validation) – Thihara Jul 08 '13 at 12:58
-
check size during upload? You could cut it if it goes over 100mb – JIV Jul 08 '13 at 13:19
-
As I write in other question, you can try this: [http://stackoverflow.com/a/31473567/4021734][1] [1]: http://stackoverflow.com/a/31473567/4021734 – svishevsky Jul 17 '15 at 10:24
2 Answers
2
You can't, because javascript
doesn't provide any way to read the contents of a file
that is stored locally.
You have to do it on server side. And its always a better option to validate on server side

Suresh Atta
- 120,458
- 37
- 198
- 307
-
1@kedar IMHO No.You have to do it on serverside only .And do not depend on client validation.It can easily by passed. – Suresh Atta Jul 08 '13 at 13:04
-
@johnchen902 java is tagged because,gwt can code in java and compiles to javascript. – Suresh Atta Jul 08 '13 at 13:49
0
You can do that using W3C Files API. There is a GWT wrapper for it at http://www.vectomatic.org/libs/lib-gwt-file.

Loša
- 2,621
- 2
- 14
- 19