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?

3
  • 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. May 7, 2013 at 16:06
  • Also related: File System access from Firefox Extension. Furthermore, in addition to their filesystem API for browser extensions, Mozilla also implemented a Device Storage API 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 7, 2013 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! May 7, 2013 at 16:21

2 Answers 2

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.

3
  • Thank you! Guess I'll check for another option... maybe some sort of standalone node.js server... May 7, 2013 at 16:07
  • Node.js won't help you read the users filesystem. Are you looking to use javascript to enumerate through files on your server?
    – romo
    May 7, 2013 at 16:14
  • I must enumerate files at the client, not at the server. But I have some odd requirements, that allow me to implement and "install" both the client and the server at the same machine. May 7, 2013 at 16:19
1

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

1

Not the answer you're looking for? Browse other questions tagged or ask your own question.