function chmod_r($path, $filemode) { if (!is_dir($path)) { return chmod($path, $filemode); } $dh = opendir($path); while ($file = readdir($dh)) { if ($file != '.' && $file != '..') { $fullpath = $path.'/'.$file; if (!is_dir($fullpath)) { if (!chmod($fullpath, $filemode)) { return false; } } else { if (!chmod_r($fullpath, $filemode)) { return false; } } } } closedir($dh); if (chmod($path, $filemode)) { return true; } return false; } |
usage:
chmod_r('your/path', 0777); |
Hi, just use
chmod -R
for recursive
Hi, this a PHP implementation. chmod -R would work in a shell.