• 0

Directory Listing using PHP


Question

I was wondering if any of you PHP guys out there knew how to do a simple directory listing using PHP? I have a public upload folder - http://www.zollonet.com/public, and I want to have a complete directory listing.

I can have a normal directory listing, but its only viewable when I don't have a index.php file in it.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Here's a starting point you can use, from php.net:

<?php
chdir($folder);
$folder = getcwd();

echo "
$folder
";

function folder($data_folder) {

$handle=@opendir($data_folder);
echo "<blockquote>";
while (@$file = readdir ($handle)) { 
  if (is_dir($file)) {
  echo "<a href=index.php3?id=253&folder=";
  echo htmlentities(urlencode($data_folder));
  echo "\\\\";
  echo htmlentities(urlencode($file));
  echo "><font size=2 color=blue face=Tahoma>$file</font></a>
"; 

  } else {
  echo "<font size=2 face=Tahoma>$file</font>
";   
  }

}
echo "</blockquote>";
}

folder($folder);
?>

Hope that gives you a start!

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.