问题
I'd like to scan a directory on my server, using JS, and create a link to the most recent file in the dir.
My server doesn't disallow directory listings; I can see the contents of the folder if I navigate to it.
Is it possible to do this in straight JS?
回答1:
All Javascript can do is HTTP requests and read whatever your server responds with. If your server doesn't give you any sort of directory listing over HTTP, then there's very little you can do with Javascript. If it does give you a directory listing you could try to parse it, but you still can't create any files or links on the server purely with client-side Javascript. This really calls for a server-side solution (PHP, Python, Ruby, C#, shell scripts; whatever you're comfortable writing).
来源:https://stackoverflow.com/questions/35404637/read-remote-directory-with-client-side-javascript