1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2010
    Rep Power

    Question Download list of files from server?


    I only have skin-deep knowledge of JavaScript.

    Before bothering with a server-side scripting language, I was wondering if JavaScript could download the list of files located in a directory on the server, and use them to fill a listbox in the browser:

    That way, I would just have to enable directory listing in that directory on the server, and only use Javascript.

    Thank you.
    Attached Images
  2. #2
  3. Lord of the Dance
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Oct 2003
    Rep Power
    JavaScript does support doing http(s) request, mostly known as AJAX.
    You could call an URL with directory listing enabled, and then parse the result (html formatted) with a DOM handler for any links in it.

    My recommendation is that you use a proper server side language to provide the file list in a better format for processing - so you don't need to parse a html page.
    Whether you call it directly during the page request or through AJAX is all up to you.
  4. #3
  5. Headless Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Washington, USA
    Rep Power
    It would (should) be really easy to make a server-side page that outputs a JSON list of the files. Call that with AJAX and render the list however you want.

IMN logo majestic logo threadwatch logo seochat tools logo