Jump to content

Question on directory listing


jimbowvu80s

Recommended Posts

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 when I change the path to look at something outside the web server directory I get zero results back.

 

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>";

                }

        }

}

 

?>

Link to comment
https://forums.phpfreaks.com/topic/223022-question-on-directory-listing/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.