Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2008
    Location
    Osceola, Indiana
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #3
    New to the CF scene
    Join Date
    Dec 2008
    Location
    Osceola, Indiana
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    New to the CF scene
    Join Date
    Dec 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •