PHP/File Directory/opendir
Listing directory
<source lang="html4strict">
<?php
$dirname = "C:\\Apache\\bin";
$dir = opendir( $dirname ); while( false != ( $file = readdir( $dir ) ) ) { if( ( $file != "." ) and ( $file != ".." ) ) {$file_list .= "
} } closedir( $dir );
?> <html>
<head> <title>Listing directory</title> <head> <body>
Files in <?php echo( $dirname ); ?>
-
<?php echo( $file_list ); ?>
</body>
</html>
</source>
Reading a Directory Listing Using opendir()
<source lang="html4strict">
<?php
$dr = @opendir("/tmp/"); if(!$dr) { echo "Error opening the /tmp/ directory!
"; exit; } while(($files[] = readdir($dr)) !== false); print_r($files);
?>
</source>