• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Validation Error For File Size...!

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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..!
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic