views:

86

answers:

4

Can JQuery/JavaScript read/get the file content on the client side, where the file is an image or a text, and store it in a variable?

EDIT: can the file putted in the be handled on the client??

+2  A: 

No, javascript or any javascript library is not able to read contents from disk clientside.

You would have to use an external plugin wich allows for that such as Java.

Ikke
+4  A: 

This isn't possible, for obvious reasons once you think about the possible uses:

$(function() { //This doesn't work, just an example
  $.getFile("C:\YourPasswords.txt");
});

I'm sure that wouldn't be abused at all :)

Nick Craver
+1  A: 

For security concern, JS isn't able to read/write any client machine files. Try Java Applet if you are from Java realm, Silverlight from .NET.

Ricky
+1  A: 

You can do this using Universal Access XP with Firefox or ActiveX with IE.

You can check out example code for this from http://code.google.com/p/memonaut/source/browse/trunk/app/saver.js

The example code is for save; similar stuff should be possible for read. Hope this helps.

sonofdelphi