Results 1 to 7 of 7

Thread: PHP - Directory Listing

  1. #1

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772

    PHP - Directory Listing

    Could someone please give me an example, or point me to a place that has an example of how to do this?
    Alcohol & calculus don't mix.
    Never drink & derive.

  2. #2
    denniswrenn
    Guest
    Code:
    <?php
    
    if ($dir = @opendir("/path/to/dir")) {
      while ($file = readdir($dir)) {
        echo "$file<BR>\n";
      }  
      closedir($dir);
    }
    
    ?>

  3. #3

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Hmm. I get a parse error on line 5.
    Alcohol & calculus don't mix.
    Never drink & derive.

  4. #4

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Never mind, I fixed it. Thanks!
    Alcohol & calculus don't mix.
    Never drink & derive.

  5. #5

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    One more thing: The first two files are "." and ".." Is there a way I can exclude these?
    Alcohol & calculus don't mix.
    Never drink & derive.

  6. #6
    denniswrenn
    Guest
    Code:
    <?php
    
    if ($dir = @opendir("/path/to/dir")) {
      while ($file = readdir($dir)) {
        if($file != "." && $file != ".."){
        echo "$file<BR>\n";
        }
      }  
      closedir($dir);
    }
    
    ?>

  7. #7

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Cool, thanks.
    Alcohol & calculus don't mix.
    Never drink & derive.

Posting Permissions

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



Click Here to Expand Forum to Full Width