I have a from wherein I can upload files and I use JSP to save the files to the server. I need code to check the size of the file, before its being saved, using JAVASCRIPT
Javascript is client side ( If not used as a serverside script ) You can only call javascript when the page has been sent from the webserver. All server side code is translated into html
In some cases you are able to do that. Let say, the only files to allow user to upload are images.Than you can have hidden img tag, assign src value using javascript to a file selected and check fileSize attribute. if it is -1, that means eather it is not an image or file not found. otherwise it will be the size of an image in bytes.