<?php function treedir ($path = ".") { if ($handle = opendir ($path)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $file_path = $path . "/" . $file; echo "$file_path - "; if (is_dir ($file_path)) { if (false !== chmod ($file_path, 0777)) echo " directory, chmoded to 0777\n"; treedir ($file_path); } elseif (is_file ($file_path)) { if (false !== chmod ($file_path, 0666)) echo " file, chmoded to 0666\n"; } else echo "error\n"; } } closedir($handle); } } treedir ("test"); ?>