php rename() Access is denied. (code: 5)

前端 未结 2 2087
广开言路
广开言路 2021-01-04 11:51

So I am trying to use rename function in php.

On the first try, if the destination folder is empty or does not contain any directories with the same name as the sour

2条回答
  •  遥遥无期
    2021-01-04 12:50

    You are adding extra / in path make this like

    /**
            *   Move temp folders to their permanent places
            *
            *   $module_folder = example (violator, pnp, etc)       
            *   $folders = name of folders within module_folder
            **/
            public function move_temp_to_permanent($module_folder, $folders){
                $bool = false;
    
                $module_folder_path = realpath(APPPATH . '../public/resources/temps/' . $module_folder);
    
                $module_folder_destination_path = $_SERVER['DOCUMENT_ROOT'] . '/ssmis/public/resources/photos/' . $module_folder . '/';
    
                foreach($folders as $folder){
                    $bool = rename($module_folder_path . $folder, $module_folder_destination_path . $folder);
                }
    
                return $bool;
            }
    

    you can also echo the path you prepared so you can check its right or not

提交回复
热议问题