wood burning stoves
The moose likes HTML, CSS and JavaScript and the fly likes creating a fileobject usign javascript 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 "creating a fileobject usign javascript" Watch "creating a fileobject usign javascript" New topic

creating a fileobject usign javascript

Rajani Panchumarthy

Joined: Jan 27, 2009
Posts: 22

I am trying to validate a file that needs to be uploaded,<input type="file" />in JSP using javascript.

The following ActiveXObject is used to retrieve the file object:

But, I get script error "Automation server cannot create object". This error is related to security issue in IE. Moreover, this does not work in Mozilla.

Do you have idea of how to get the file object in Javascript other than the above ActiveXObject.

This is mainly for validation of file content , file length at frontend itself.

Thank you.

Ayoma Wijethunga
Ranch Hand

Joined: Mar 07, 2010
Posts: 38


So you simply want to validate the file input in the client side, itself. Think of it like this. JavaScript is a client side language. So, browser has to access the client's file system, in order to check the size of the file. I don't think any of the browser (except few outdated browsers) will accept this, as it is a major security risk.

So my suggestion is to use a Flash based file uploader. Swfupload support this kind of validations in client side itself. Don't know if it is possible with JavaFX. If possible you can give it a try.


AyomaOnline - CodeGreed
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
As Ayoma stated, you need to look at a different technology or do it all on the server.

I agree. Here's the link: http://aspose.com/file-tools
subject: creating a fileobject usign javascript
It's not a secret anymore!