File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Validation Error For File Size...! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Validation Error For File Size...!" Watch "Validation Error For File Size...!" New topic
Author

Validation Error For File Size...!

Mallikarjuna Chejerla
Greenhorn

Joined: Jul 24, 2006
Posts: 16
Hi,

I am writing logic for checking file size of uploading files at client side as follows.

var fso=new ActiveXObject("Scripting.FileSystemObject");
var f=fso.getFile(file);
return fso.getFile(file).size;


This code create problem in IE 7.0 and Mozilla and Firefox. Please Tell me How can i write a client side function to check file size which will work on all browsers.

Thanks in Advance..!
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
ActiveX is IE only [and IE that has ActiveX enabled]

You are not going to be able to do it with the other browsers.

Eric
Mallikarjuna Chejerla
Greenhorn

Joined: Jul 24, 2006
Posts: 16
Hi,

Yes you are right. And i know that Activex is only for IE. But in IE 7.0 it is not working with the code which i have posted.I need a sample code for checking file size of a uploaded File at client side in Javascript.

That should work with IE 6.0,7.0,Mozilla and Firefox.

Thanks in Advance!!!
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You are not going to get sample code that works in the other browsers. JavaScript has strong security to keep the user's safe. Reading files on the local machine is something that is not secure.

If it is not working in IE7, it is because ActiveX is not enabled or the path is not correct.

You will have to look at another technology such as an applet, or you need to submit to the server and deal with it there.

Eric
 
GeeCON Prague 2014
 
subject: Validation Error For File Size...!