1

I've been searching the web for a way to recursively enumerate files inside a directory through Javascript, inside a browser.

Looking at the File API I could not find anything.

Could someone point me to some other API or tell me if it is possible to accomplish this?

  • Thank you for your comment! I was hoping that because the applications are moving to the browser, this kind of API would be finally present, or at last that there was a more portable way. – Vinícius Gobbo A. de Oliveira May 07 '13 at 16:06
  • Also related: [File System access from Firefox Extension](http://stackoverflow.com/questions/2316708/file-system-access-from-firefox-extension). *Furthermore*, in addition to their filesystem API for browser extensions, Mozilla *also* implemented a [Device Storage API](https://developer.mozilla.org/en-US/docs/WebAPI/Device_Storage) for Firefox OS. That does exactly what you want (`deviceStorage.enumerate`) but the API is only available for OS apps, not web pages. – apsillers May 07 '13 at 16:19
  • An extension mechanism is an option. But it must work very closely on Chrome, Firefox, Opera and Safari (I don't care about IE). If you could point others extensions that work reliably at last on Chrome and Firefox, that would be great! – Vinícius Gobbo A. de Oliveira May 07 '13 at 16:21

2 Answers2

2

Javascripts access to local files is very restricted. You can't search or enumerate through files, only access specific ones which a user has deliberately selected.

What you could do however is write a Java applet (which would likely have to be signed to get the requisite permissions) which would do the enumeration for you and make it accessible via Javascript. This of course limits you to platforms and users with Java installed, but that's pretty much the only way you could manage it.

PhonicUK
  • 13,486
  • 4
  • 43
  • 62
1

You can't do this. JavaScript doesn't have access to the file system.

tymeJV
  • 103,943
  • 14
  • 161
  • 157