[Javascript] Finding file size using java script

Abhishek_Ghosh Abhishek_Ghosh at satyam.com
Mon Mar 7 07:20:03 CST 2005


Hi,

            I am working on jsp's and have an issue in uploading files. I am
allowed to upload at the max of 20MB on the server, but the issue is often
user ignores the message and tries to upload more than 20MB. The request
goes to the server and the server then throws an error message. This process
however takes some time to get executed. I would like to have a client side
validation done for the size of the file. To do this I cannot use ActiveX
objects as the business requirements strictly restricts use of ActiveX
Objects. The other option is to use the following code :

 

                                                var fileObj =
document.fileSizeChecker.fileUpload.value;

                                                var myFile = new
File(document.fileSizeChecker.fileUpload.value);

            myFile.open("r");

alert('myFile length: ' + myFile.getLength());

 

            Using the above code produces the following javascript error
"'File' is undefined". Please suggest how to bail out of this error or an
alternate method of achieving the purpose.

            Thanx in advance.

------------------------------------------------------- 
Regards, 
Abhishek Ghosh 
GEPS, GE-GDC, Satyam Computer Services Limited 
Satyam Technology Centre, 
Hyderabad - 500043 
Phone : (O)+91 40 55233562 (Extn-3062) 
             (R)+91 40 55233562 (Extn-2756) 
Mobile : +91 94408 77249 
e-mail : Abhishek_Ghosh at satyam.com 
Web : www.satyam.com 

 

************************************************************************** 
This email (including any attachments) is intended for the sole use of the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or
distribution or forwarding of any or all of the contents in this message is
STRICTLY PROHIBITED. If you are not the intended recipient, please contact
the sender by email and delete all copies; your cooperation in this regard
is appreciated.
**************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20050307/2af58136/attachment.htm>


More information about the Javascript mailing list