0

Scenario: I am creating a personal home page that i plan for using in safari/chrome/Firefox and I have a folder with images. I want to display a random image as the background of the page.

My solution to this was to create an array with all the images as separate links as the objects of the array. My JS works with a pre-made array of links but I have no clue on how to create an array from a directory.

I don't mind using jquery if required but i cant have server side php (or anything else) since i am linking the local html file to the new tab page.\

The html file is in the directory / and the images in /img .

4

1 Answer 1

1

This can't be done. You're going to need something on the server side to read the directory that is on your server. Javascript (including jQuery) running on the user's browser doesn't have access to list directories on your server.

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

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.