View Full Version : question about directory listing.

12-07-2008, 05:24 AM
hi i need help with how to make my websites directorys show up like a directory listing. where it will display all the files in that directory. im completly new to php and this stuff if anyone could help that would be grate thanks.

12-07-2008, 05:53 AM
Might help:

12-07-2008, 07:53 AM
ok i followed the code and now im wondering how i apply it to the directorys. like if im just supposed to add it to the index.php or something like that or what? im sorry but i am completly lost on this stuff. i have no experience.

12-08-2008, 03:00 AM
I've recently added this to my site to show all the files in the uploads directory.

$dir = "http://mysite.com/files/uploads/"; // Name of the directory you want to view using the script

// 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 : filetype: " . filetype($dir . $file) . "/n";

if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "$file<br />";

For me I just have that code in the index.php page in the uploads directory