1

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

RAS
  • 8,100
  • 16
  • 64
  • 86
kedar
  • 103
  • 1
  • 11
  • 1
    possible 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 Answers2

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
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