Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Validation Error For File Size...!

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic