1

Trying to see if this is possible -

1.) User logs into our site
2.) Points to a directory
3.) The javascript code reads contents of the directory, shows thumbnails for any jpeg/gif in those directories. This all without uploading all the photos to the server. Kind of a semi desktop app.

Point 3 is something I have never done, is this possible for an online application to do ?

PlanetUnknown
  • 3,956
  • 4
  • 49
  • 67

3 Answers3

3

You can't do this...yet (unless you're using a prerelease of Chrome 9). There are some APIs coming down the pike that will make this possible in browsers that support them; there's a description of using them in this article.

But right now, no. To do this, you'll need to use a technology that allows local file access, such as a signed Java applet (normal unsigned ones obviously can't do this) or, on a severely limited number of platforms and browsers, an ActiveX control.

Update: Sorry, the new JavaScript APIs I mentioned above don't give you (user-granted) access to any old directory on their system. They do give you access to the file system, but it's a sandboxed file system. So you'd have to have the users move the files into the sandbox (which you could do via the File API and with drag-and-drop, keeping it an entirely client-side thing, no uploading required). But that isn't quite what you described.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • As I understand, that just allows you to create files; you cannot read an existing directory. – SLaks Feb 13 '11 at 16:25
  • @SLaks: You're both correct and incorrect. :-) In reverse order: It doesn't just allow you to create files; you can read files (and directories) as long as they're in the sandboxed file system. But you're quite correct, I hadn't looked closely at the directory stuff and I think, looking again, that it doesn't allow (user granted) access to directories outside the sandbox. I've updated. – T.J. Crowder Feb 13 '11 at 16:38
  • Can I do this by a standalone HTML5 application ? – PlanetUnknown Feb 14 '11 at 12:26
  • @Planet: Sure, you can use a platform like Adobe AIR or XULRunner or Prism (I haven't done it, myself): http://stackoverflow.com/questions/4869613/html5-for-desktop-application-development (XULRunner isn't really HTML5, but it's a lot of the same technologies.) – T.J. Crowder Feb 14 '11 at 13:15
1

No; this is not possible.

Javascript cannot directly interact with the user's local filesystem

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
1

No, it is not possible to access any of the clients files using JavaScript as that would be a security risk.

Alan Haggai Alavi
  • 72,802
  • 19
  • 102
  • 127