1

Possible Duplicate:
PHP list of specific files in a directory

I want to list all the directories and files that are there in my directory. How i can do this? Below is my code

if(opendir("user_files/".$uid."/")) {
var_dump(readdir("user_files/".$uid."/"));
}
Community
  • 1
  • 1
Ali Hassan
  • 39
  • 3

1 Answers1

0

This is another way to List Files in your folder using FilesystemIterator

$dir = __DIR__;
$fi = new FilesystemIterator($dir, FilesystemIterator::SKIP_DOTS);
echo "<ul>";
printf("<b>Total Files :  %d</b>", iterator_count($fi));
foreach ( $fi as $file ) {
    printf("<li>%s : %d</li>", $file->getFileName(), $file->getSize());
}
echo "</ul>";
Baba
  • 94,024
  • 28
  • 166
  • 217