List files in a directory using only javascript

No, Javascript doesn't have access to the filesystem. Server side Javascript is a whole different story but I guess you don't mean that.


Very late to this party, but my google search for this exact request led me here.

The answer is "not really", but I've found the frankenstein of hacks elsewhere: If +Indexes is (or can be) enabled in the .htaccess for the folder containing the files you want to list, then use XMLHTTPRequest with the folder name as the url (which will return an html page listing the files).


I don't know if you architecture allows it but ikf you can install and use node.js as its node API mentions, you can interact with the filesystem by requiring the fs module.

This is the environment Node.js relies on:

Node eventually wants to support all POSIX operating systems (including Windows with MinGW) but at the moment it is only being tested on Linux, Macintosh, and Solaris. The build system requires Python 2.4 or better. V8, on which Node is built, supports only IA-32 and ARM processors. V8 is included in the Node distribution. To use TLS, OpenSSL are required. There are no other dependencies.

You can run It side-by-side with another web app. and this will avoid blocking your web application if the interaction with the filesystem takes too long.