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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.