php-chmod / Blog: Recent posts

Recursively chmod files and folders with different permissions.

Modified by Jan Zumwalt - NeatInfo.com Ver 2012-03-05

Recursively chmod files and folders with different permissions.

This is a PHP alternative to using: \n
exec("find ".$path." -type f -exec chmod 644 {} \;");
exec("find ".$path." -type d -exec chmod 755 {} \;");

Originally by Jeppe Toustrup

Usage: chmod_r($path, $filePerm, $dirPerm);
Example: chmod_r("./", 0644, 0755);

$path: Relative or absolute path to the file or directory to process.

$filePerm: The permission for files.

$dirPerm: The permission for directory folders.

Returns TRUE if the path was found, FALSE if the path was not found.

The permissions are in octal format, so a leading zero "0" is needed

in front of the permission level. See http://php.net/chmod

by: Jan Zumwalt - NeatInfo.com   Version: 2012-03-05

Posted by Jan Zumwalt 2012-03-05