www.webdeveloper.com
Results 1 to 5 of 5

Thread: Javascript file browser

  1. #1
    Join Date
    Jul 2009
    Posts
    48

    Lightbulb Javascript file browser

    Hello all,

    i was wondering if there was a script out there that can see what files are in a particular folder then show them in a web "file browser", Any help

  2. #2
    Join Date
    Oct 2003
    Location
    Andover, UK
    Posts
    945
    This is impossible in all web languages as it would constitute a major security risk. The closest you can come is to use an file upload field field to allow people to browse local folders on their computer, but even that won't return the list of files to JS.

  3. #3
    Join Date
    Jul 2009
    Posts
    48
    so not even if the folders are on the webserver

  4. #4
    Join Date
    Oct 2003
    Location
    Andover, UK
    Posts
    945
    Ah - you didn't say a web server folder.

    Then yes, but JS can't do this by itself, you'll need something like PHP which will then return the files to JS via ajax.

    Here's a simple PHP script to read all files in a dir:

    Code:
    <?php
    $dir = "/etc/php5/";
    
    // Open a known directory, and proceed to read its contents
    if (is_dir($dir)) {
        if ($dh = opendir($dir)) {
            while (($file = readdir($dh)) !== false) {
                echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
            }
            closedir($dh);
        }
    }
    ?>

  5. #5
    Join Date
    Jul 2009
    Posts
    48
    is there a way to put it into a table with my own icons and the actual folder names because when i added that nothing happend

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles