Bogdan
Bogdan

Reputation: 461

add image with jquery

How can I add all images inside a folder to a div using jquery? and then is it possible that when I click on a link to change the folder, delete all current images and then add the new ones from the new folder?

Upvotes: 1

Views: 217

Answers (2)

Nathan Anderson
Nathan Anderson

Reputation: 6878

You cannot accomplish this entirely with jquery. You would need an intermediary script on the server that would accept requests for a list of images in a given directory, and then return that information to the client, which you could from there easily do what you want.

Upvotes: 0

alex
alex

Reputation: 490153

jQuery has the same rights as JavaScript to access the file system in a browser environment - none.

The sane way would be to have some server side code hand an array to your JavaScript.

The utterly insane way would be to name your images \d.jpg and have JavaScript request them until it 404s. This is so bad, you should never do it. I'm just mentioning this to say it is possible.

Upvotes: 5

Related Questions