Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-07-2008, 04:24 AM   PM User | #1
kornmusic420
New to the CF scene

 
Join Date: Dec 2008
Location: Osceola, Indiana
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
kornmusic420 is an unknown quantity at this point
question about directory listing.

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.
kornmusic420 is offline   Reply With Quote
Old 12-07-2008, 04:53 AM   PM User | #2
rangana
Senior Coder

 
rangana's Avatar
 
Join Date: Feb 2008
Location: Cebu City, Philippines
Posts: 1,752
Thanks: 65
Thanked 372 Times in 365 Posts
rangana will become famous soon enoughrangana will become famous soon enough
Might help:
http://www.spoono.com/php/tutorials/tutorial.php?id=10
http://www.liamdelahunty.com/tips/ph..._directory.php
__________________
Learn how to javascript at 02geek

The more you learn, the more you'll realize there's much more to learn
Ray.ph
rangana is offline   Reply With Quote
Old 12-07-2008, 06:53 AM   PM User | #3
kornmusic420
New to the CF scene

 
Join Date: Dec 2008
Location: Osceola, Indiana
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
kornmusic420 is an unknown quantity at this point
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.
kornmusic420 is offline   Reply With Quote
Old 12-08-2008, 02:00 AM   PM User | #4
toxictoad
New to the CF scene

 
Join Date: Dec 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
toxictoad is an unknown quantity at this point
I've recently added this to my site to show all the files in the uploads directory.

Code:
<?php
$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";
        }
        closedir($dh);
    }
}

if ($handle = opendir('.')) {
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
            echo "$file<br />";
        }
    }
    closedir($handle);
}
?>
For me I just have that code in the index.php page in the uploads directory
toxictoad is offline   Reply With Quote
Reply

Bookmarks

Tags
directory, listing, php code

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:04 PM.


Advertisement
Log in to turn off these ads.