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 containin
If the directory is on the same domain, and your webserver is setup to show directory indexes, then you could use javascript to request the url and load it into the dom for data extraction. This is brittle, and doesn't sound like it would make for a good plugin, much less good for anything but a one off task. But, you could do it.
The other suggestions of having serverside script output json or xml would be an improvement.
You have to get the list from your server through JSON or XML. Because of this, you can't do this in any way with javascript on servers you have no control over. Also, access to client side files is actively avoided for security reasons.
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.
You would need to create a web service to fetch the list of files. You can't use ajax to directly fetch the directory listing because ajax calls are restricted to the domain.