Possible Duplicate:
List all folders on my computer (php)
I have tried:
$handle = opendir($path);
But what is the path? I put everything but the kitchen sink in there! I can’t get it to work. I’m on my localhost right now.
I did:
opendir(dirname(__FILE__));
Here is what a got to work…
$dir = dirname(__FILE__);
// 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."<br />";
}
closedir($dh);
}
}
Will do some cleaning to get the information I was wanting. However, thanks to “some” of you on Stackoverflow I like this code alot better for localhost application.
foreach(glob("*") as $filename)
{
echo $filename."<br />";
}
You’re looking for
glob(for easy stuff) orDirectoryIterator(for a more OOP approach).(Examples from the respective doc pages w/ some modifications)