This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread 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 Murach's Java Servlets and JSP this week in the Servlets 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: 60752
    
  65

Please do not post the same question more than once.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
Consider Paul's rocket mass heater.
 
subject: Client Side validation for checking the file size using javascript before sending request to server
 
Similar Threads
Strange incomplete page loaded
only half jsp displayed sometimes
What is good practice for FORM VALIDATION ?
check if file exists
XMLHttpRequest.open() Exception