Log in

View Full Version : PHP Directory Listing



jimbowvu80s
12-30-2010, 07:26 PM
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>";
}
}
}

?>

Nile
12-30-2010, 08:51 PM
You can't list files from another website - is that the question?

jimbowvu80s
12-30-2010, 08:56 PM
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.

Nile
12-30-2010, 09:10 PM
No, I dont think you can.

traq
12-31-2010, 03:01 PM
It is possible to use PHP locally, from the command line (http://us3.php.net/manual/en/features.commandline.php). 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.