php - list folders and files on localhost
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/657562/list-all-folders-on-my-computer-php">List all folders on my computer (php)</a>  </p>
</blockquote>



<p>I have tried:</p>

<pre><code>$handle = opendir($path);
</code></pre>

<p>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.</p>

<p>I did:</p>

<pre><code> opendir(dirname(__FILE__));
</code></pre>

<p>Here is what a got to work...</p>

<pre><code>$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."&lt;br /&gt;";
        }
    closedir($dh);
    }
}
</code></pre>

<p>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.</p>

<pre><code>foreach(glob("*") as $filename)
{
echo $filename."&lt;br /&gt;";
}
</code></pre>
