Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I iterate through files in Javascript

Is it possible to iterate through a collection of files in Javascript? I am writing a jQuery plugin that takes either an array of images or, I was hoping, a directory containing a list of images. E.g. either:

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

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

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

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

like image 841
Fermin Avatar asked Mar 12 '26 18:03

Fermin


1 Answers

You should use server side language to provide array of images in JSON or similar. There is no way Javascript can access local files. That would be serious security issue.

like image 99
dusoft Avatar answered Mar 14 '26 06:03

dusoft



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!