문제

I am setting up renaming functionality a part of a crud system for dirs, and right setting up a process to rename sub-directory of an uploads directory and the renaming process is working meaning dirs are being renamed accordingly yet I am getting error codes from opendir. Apparently the paths are not being found because they're paths that had been renamed. Not sure how to remedy this problem which is the million dollar question??

controller:

private function _edify_dirs_recursive($targets, $new_dirs)
{
    $targets = rtrim(preg_replace(array("/\\\\/", "/\/{2,}/"), "/", $targets), "/");
    $new_dirs = rtrim(preg_replace(array("/\\\\/", "/\/{2,}/"), "/", $new_dirs), "/");
    $explode_targets = explode(',',$targets);
    $explode_new_dirs = explode(',',$new_dirs);

    foreach($explode_targets as $target_keys):
        $dirs_obsolete = "./uploads/$target_keys";
        foreach($explode_new_dirs as $new_dirs_keys):
            $dirs_new = "./uploads/$new_dirs_keys";
            $chid_generator = @rename($dirs_obsolete,$dirs_new);
            if($dhandle = @opendir("./uploads/$target_keys"))
            {
                while(FALSE !== ($entry = @readdir($dhandle)))
                {
                    { true; }
                }
                //closedir must be within if logic
                @closedir($dhandle);
            }
        endforeach;
    endforeach;
}
도움이 되었습니까?

해결책

Since you've just renamed ./uploads/$target_keys to ./uploads/$new_dirs_keys, you shouldn't be trying to opendir("./uploads/$target_keys"), but opendir("./uploads/$new_dirs_keys").

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top