Posted By

madc on 11/06/11


Tagged

php recursive chmod


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

boksiora


Recursive chmod in PHP


 / Published in: PHP
 

URL: http://madcity.at/

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

  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. }

Report this snippet  

You need to login to post a comment.