Saturday, October 04, 2008

php sub folder scan

you can use php to scan all file in sub folder from this code

<?php
// *** requires PHP5 ***
// search for gif files (can be empty for all file)
$filter = ".gif";
// path to the directory you want to scan(can be .. to search all drive)
$directory = './';
$it = new RecursiveDirectoryIterator("$directory");
foreach(new RecursiveIteratorIterator($it) as $file)
{
  if (!((strpos(strtolower($file), $filter)) === false) || empty($filter))
  {
    $items[] = preg_replace("#\\\#", "/", $file);
  }
}
sort($items);
print_r($items);
?>

but if your server not PHP5 don't worry please see this link http://www.php.net and find class RecDir