How can I iterate over files in javascript

Is it possible to iterate through a set of files in Javascript? I am writing a jQuery plugin that accepts either an array of images, or, I hoped, a directory containing a list of images. For instance. or:

['image1.jpg','image2.jpg','image3.jpg']

or 'http://somedomain.com/images/'

Then I would like to be able to iterate over the above domain and take the file name from each of the files in the folder.

I read about FileSystemObject , but it will only be available in IE, is there an equivalent that can be used in all browsers?

+3
source share
4 answers

JSON . Javascript . .

+4

.

JSON XML. - javascript , . , .

0

- . ajax, , ajax .

0

If the directory is in the same domain and your web server is configured to display directory indexes, you can use javascript to query the url and load it into dom to retrieve the data. It's fragile and doesn't sound as if it were made for a good plugin, which would be much worse for anything but one task. But you could do it.

Other suggestions that serveride script output json or xml will be an improvement.

0
source

Source: https://habr.com/ru/post/1734942/


All Articles