i want to write a page that will traverse a specified directory.... and get all the files in that directory...
in my case the directory will only contain images and dis
Hi you can use DirectoryIterator
try {
$dir = './';
/* @var $Item DirectoryIterator */
foreach (new DirectoryIterator($dir) as $Item) {
if($Item->isFile()) {
echo $Item->getFilename() . "\n";
}
}
} catch (Exception $e) {
echo 'No files Found!
';
}
If you want to pass directories recursively: http://php.net/manual/en/class.recursivedirectoryiterator.php