Thursday, September 22, 2011

How do I read the files on the server directory?

I have some image files (jpg, gif) on the same directory where the HTML file is, but they change from time to time. Is there a JavaScript code to read the content of the directory so I can create an Array and then change the image on the browser dynamicly?How do I read the files on the server directory?
There are a couple of ways around this. First generate the page dynamically at load time to include an array of image URL's in the HTML source that the JavaScript can reference it. For something with a little more coolness factor, you can write a script that returns an XML file with the image URL's and send a request to the server script from your JavaScript using AJAX. The problem with any approach like this is security, making a listing available to your script also means making it available to ';alternative users,'; hackers. A listing may or may not be important to such individuals by itself, but it might help them if they compromise the server though some other means.

No comments:

Post a Comment