0

Is it possible to use Javascript to list all the files contained in a subfolder?

I have a bunch of images that need to be linked too, but I would like it to be dynamic because the list will be changing a lot.

Thankyou!!!

1 Answer 1

1

Is it possible to use Javascript to list all the files contained in a subfolder?

No. You would usually set up a simple server side script that does the listing (e.g. using PHP's glob()), and output a JSON array, for example.

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

7 Comments

It depends. If the oparating system from server is Windows, you can use Jscript. JScript is a "extension" of Javascript.
@reporter I don't see how - JScript running on the client's browser can not do anything on server side, either
so then, how would i pass the file name array from php to javascript? can the two even be used together?
@Alex you could use Ajax to make a call to a PHP script that outputs JSON. Or you could do a <script src='myfile.php'> and have myfile.php output a JSON array
@Pekka If you use an IIS you the option to use vbscript or jscript language by default. Create an .asp file (asp-classic) and read your directory. On client side, if you want to read a folder structure either you have to install an IIS or create a WSH Script that uses JScript as language. If you want use just the general javascript you can't do it (but I think you can do that with new version of javascript (Keyword: HTML5). But I'm not sure about this)
|

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.