Listing directory : opendir « File Directory « PHP






Listing directory

 
<?php   
  $dirname = "C:\\Apache\\bin";


  $dir = opendir( $dirname );

  
  while( false != ( $file = readdir( $dir ) ) )
  {
    if( ( $file != "." ) and ( $file != ".." ) )
    {
      $file_list .= "<li>$file</li>";
    }
  }

  closedir( $dir );
?>

<html>

 <head>
  <title>Listing directory</title>
 <head>

 <body>
  <p>Files in <?php echo( $dirname ); ?> </p>
  <ul>
    <?php echo( $file_list ); ?>
  </ul>
 </body>

</html>
  
  








Related examples in the same category

1.Reading a Directory Listing Using opendir()