1

Is there a way to, with JavaScript, get a list of files from a target folder?

I need to search a folder for XML-files and, if there are any, save the names of them in an array.

Thank you!

3 Answers 3

3

HTML5 finally provides a standard way to interact with local files, via the File API specification.

http://www.html5rocks.com/en/tutorials/file/dndfiles/

Sign up to request clarification or add additional context in comments.

Comments

2

No. JavaScript works only in the client. Without AJAX calls, JavaScript has no way of looking through folders on the server or on the client's computer.

A language like PHP or Ruby has a part in the server that would allow it access to the file system on the server, but not plain JavaScript.


As sofrito notes below, HTML5 now has a File API which can be used to manipulate files. However, the API can't do all the things that I listed above: Javascript still can't look through folders on your computer or another person's with the same ability as a C++, Java, Python or Ruby program.

Comments

1

No, not really. But you can statically type the array.

var xml = [ "something.xml", "somethingelse.xml", "anotherthing.xml" ];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.