Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic