This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSP and the fly likes Client Side validation for checking the file size using javascript before sending request to server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Reply locked New topic
Author

Client Side validation for checking the file size using javascript before sending request to server

Ravi Saluru
Greenhorn

Joined: Nov 01, 2011
Posts: 10

Hi,

I have a requirement to check the file size which is being uploaded before sending the file to the server for the validation. The maximum file limit set is 10 MB for the upload, beyond which it is not to be allowed.

I tried couple of things,

For Firefox and Chrome -
var file = document.getElementById(idName).files[0];
file.size returns the correct size. But unfortunately this doesn't work with the IE(Sometimes I hate IE).

I tried to Google any solution for the IE Browser, some people suggested to use ActiveX, but sadly I can't use it.

Any solution for browser independent javascript solution ?

Thanks


Thanks and Regards,
Ravi
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61082
    
  66

Please do not post the same question more than once.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Client Side validation for checking the file size using javascript before sending request to server