1

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?

jugglervr
  • 11
  • 2
  • 5
  • 1
    Look at the html code your server generates for a directory and write a selector to extract the name of the most recent file (or whatever you want). – georg Feb 15 '16 at 08:45
  • So your server ***allows*** directory listings? – deceze Feb 15 '16 at 08:47
  • yeah. lame double-negative but I phrased it that way because the "smart" thing to do is to disallow... so I was calling out that I'm not doing that for this project. :) – jugglervr Feb 15 '16 at 08:53

1 Answers1

4

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).

deceze
  • 510,633
  • 85
  • 743
  • 889