wmguk Posted October 19, 2009 Share Posted October 19, 2009 Hi, I need a script to read all files in a folder and set to 777. Can anyone help out please? Link to comment https://forums.phpfreaks.com/topic/178200-chmod-script/ Share on other sites More sharing options...
GKWelding Posted October 19, 2009 Share Posted October 19, 2009 $path ios self explanatory, $filemode should be your chmod values in octal format, eg. 0755. function chmodr($path, $filemode) { if (!is_dir($path)) return chmod($path, $filemode); $dh = opendir($path); while (($file = readdir($dh)) !== false) { if($file != '.' && $file != '..') { $fullpath = $path.'/'.$file; if(is_link($fullpath)) return FALSE; elseif(!is_dir($fullpath) && !chmod($fullpath, $filemode)) return FALSE; elseif(!chmodr($fullpath, $filemode)) return FALSE; } } closedir($dh); if(chmod($path, $filemode)) return TRUE; else return FALSE; } Link to comment https://forums.phpfreaks.com/topic/178200-chmod-script/#findComment-939610 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.