Reputation: 142
I am trying to build a simple website with just an index file and a folder full of icons for our internal purpose. I am making this so that anyone in our team can just access the link and download the icons whenever needed without our help. I am trying to read the icons file name from the folder automatically, so every time we update the folder with new ones we don't have to edit the HTML. I know only JavaScript. Please help me.
Upvotes: 0
Views: 104
Reputation:
An alternative could be to produce a filelist of the files via a script or batch file (depending on OS, something like - in psudeo - ls path/to/images > filelist.txt
) which redirect the output to a file that ends up in the same root as the index and images.
This file could then be read via fetch()
or XMLHttpRequest()
and parsed on client side to provide the basis for the links to the updates files.
This would require an extra step in the pipe-line of course, but could easily be automated using a listener for the image directory that triggers the script, part of your project setup and so forth.
Upvotes: 2
Reputation: 830
This is not possible. In your case Javascript is running in the browser (client-side). It has no access to the servers filesystem. You need a server-side dynamic web-service (php, node.js, ...)
Upvotes: 1