tags:

views:

98

answers:

4

Hi,

Is there no way for javascript hosted on a webserver to read a file on a client's local machine? (this has obvious security risks). I guess I'm wondering if there's any access granting a user can do, like drag and dropping a file into the browser, or explicitly selecting a file from a popup to get around this?

I know flash 10 allows reading of a local file, just wondering if there were any method to do this in javascript.

Thanks

+1  A: 

Nope, that's not possible...

However, see this:

http://www.mozilla.org/js/js-file-object.html

Sarfraz
+2  A: 

Who on their right mind would release a browser that let JS to... oh wait, you can with activeX, but only works with IE.

Ben
More specifically, it's the Scripting.FileSystemObject ActiveX Object that lets you do this.
Matt
haha that is good, yeah it is a huge security risk, agreed.
+1  A: 

... or explicitly selecting a file from a popup to get around this ...

You could of course just upload the file to your server then...

ChristopheD
Ok yeah this should work fine for me then.
+1  A: 

There is new File API being a working draft in W3C, and it is already implemented in Firefox 3.6, see

http://demos.hacks.mozilla.org/openweb/FileAPI/
http://ajaxian.com/archives/w3c-publish-first-working-draft-of-file-api
http://hacks.mozilla.org/2009/12/w3c-fileapi-in-firefox-3-6/

Tim Babych