| Below example, reads directory information and display the listed files. 1: <?php
2:
3: function list_files($dir)
4: {
5: if(is_dir($dir))
6: {
7: if($handle = opendir($dir))
8: {
9: while(($file = readdir($handle)) !== false)
10: {
11: if($file != "." && $file != ".." && $file != "Thumbs.db"/*pesky windows, images..*/)
12: {
13: echo '<a target="_blank" href="'.$dir.$file.'">'.$file.'</a><br>'."
";
14: }
15: }
16: closedir($handle);
17: }
18: }
19: }
20:
21: /*
22: To use:
23:
24: <?php
25: list_files("images/");
26: ?>
27: */
28: ?> |