Recursive chmod in PHP


/ Published in: PHP
Save to your folder(s)

Heavily based on "Recursive chmod in PHP" by Tenzer ( 03/10/08 http://snipplr.com/view/5350/ )


Copy this code and paste it in your HTML
  1. function rChmod($path, $filePerm=0664, $dirPerm=0775)
  2. {
  3. if(!file_exists($path))
  4. return(false);
  5.  
  6. if(is_file($path))
  7. chmod($path, $filePerm);
  8. elseif(is_dir($path))
  9. {
  10. chmod($path, $dirPerm);
  11.  
  12. $foldersAndFiles = scandir($path);
  13. $entries = array_slice($foldersAndFiles, 2);
  14. foreach($entries as $entry)
  15. rChmod($path.DIRECTORY_SEPARATOR.$entry, $filePerm, $dirPerm);
  16. }
  17.  
  18. return(true);
  19. }

URL: http://madcity.at/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.