Cfile And Change Permission Of Folders/subfolders

Hi i use cfile to copy now i have trouble having changing permission to 0755 need help…I need to change the folders and its subdolders

Hello roadrunner,

could you post some code, because I have no idea what is meant by "cfile".

I use the cfile extension


$myfile = Yii::app()->file->set('/../dept1', true);//a file to copy

$mynewfile =$myfile->copy($model->dept);//$model->dept is for rename for the copied file

 

and then i add this to change my file permission





function ListFiles($dir) {

 

    if($dh = opendir($dir)) {


        $files = Array();

        $inner_files = Array();


        while($file = readdir($dh)) {

            if($file != "." && $file != ".." && $file[0] != '.') {

                if(is_dir($dir . "/" . $file)) {

                    $inner_files = ListFiles($dir . "/" . $file);

                    if(is_array($inner_files)) $files = array_merge($files, $inner_files); 

                } else {

                    array_push($files, $dir);

					

                }

            }

        }


        closedir($dh);

        return $files;

    }

}




foreach (ListFiles('/../'.$model->dept) as $key=>$file){

    chmod($file,0755);

}  




but in some cases some folders dont have 0755 permission

I see. Did you tried to debug it?

  • Does the array which comes from the ListFiles() function contain the correct filepaths? (Just echo them within the foreach loop)

  • Is the chmod function returning true? (var_dump(chmod($file, 0755))

  • Did you checked that the user which the webserver is running on have the permission to change the mode of the directory/file?

when i check in windows and view all of each loop i think its ok! but in the webhost that run in unix some dont change the permission…