Results 1 to 5 of 5

Thread: PHP Directory Listing

  1. #1
    Join Date
    Oct 2009
    Posts
    26
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default PHP Directory Listing

    Is it possbile to use PHP to list directories outside of the root of the web server - for example c:\images or d:\images? I can use this script to list the files from the root down, but nothing outside of the web server directory.

    Thank you.

    <?php

    filesInDir('d:\policy');

    function filesInDir($tdir)
    {
    echo ("<p><h1>List of files in ($tdir):</h1></p><hr><br />");
    $dirs = scandir($tdir);
    foreach($dirs as $file)
    {
    if (($file == '.')||($file == '..'))
    {
    }
    elseif (is_dir($tdir.'/'.$file))
    {
    filesInDir($tdir.'/'.$file);
    }
    else
    {
    echo $tdir.'/'.$file.' --- '.date("F d Y H:i:s", filemtime('$file'))."<br>";
    }
    }
    }

    ?>

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    You can't list files from another website - is that the question?
    Jeremy | jfein.net

  3. #3
    Join Date
    Oct 2009
    Posts
    26
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    No. It's from another directory located on my web server, but it's not in the web server directory. It could be c:\images\icons.

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    No, I dont think you can.
    Jeremy | jfein.net

  5. #5
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    It is possible to use PHP locally, from the command line. I've never done it, however. I wouldn't know where to start, and I suspect there would be other programs/languages better suited to the task.

Bookmarks

Posting Permissions

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