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

    Join Date
    May 2010
    Posts
    33
    Rep Power
    9

    Question Download list of files from server?


    Hello,

    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
    Posts
    4,179
    Rep Power
    2011
    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. Impoverished Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,885
    Rep Power
    9646
    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