codingtcher.com
Theme Night
Home
Login

Change folder file permission php

Home » Tutorial Post » Change folder file permission php
<?php
function setchmod($dir, $dirPermissions, $filePermissions){
      $dp = opendir($dir);
      while($file = readdir($dp)) {
         if (($file == ".") || ($file == ".."))
            continue;

        $fullPath = $dir."/".$file;

         if(is_dir($fullPath)) {
           // echo('DIR:' . $fullPath . "\n");
            chmod($fullPath, $dirPermissions);
            setchmod($fullPath, $dirPermissions, $filePermissions);
         } else {
           // echo('FILE:' . $fullPath . "\n");
            chmod($fullPath, $filePermissions);
         }
      }
     closedir($dp);
}

setchmod($_SERVER["DOCUMENT_ROOT"], 0755, 0644);

?>

Related Post