1

I like the JavaScript equivalence of the PHP function:

echo json_encode(glob("images/*.jpg")) ?>);

is it possible ?

2 Answers 2

5

You can't scan a filesystem with javascript. If your site has empty directory indexing, you can parse the resulting html, and pull out a list of links to images.

In general, you are much better off just putting that php snippet in a file and calling it from javascript.

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

1 Comment

done it in php... work great... sometimes you have to take the right tool for the right work !
1

Javascript does not in any way/shape/form directly support file-based I/O, including reading directory contents.

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.