1

我正在为 dirs 设置重命名功能,作为 crud 系统的一部分,并正确设置了一个过程来重命名上传目录的子目录,并且重命名过程正在工作,这意味着 dirs 正在相应地重命名,但我从 opendir 收到错误代码. 显然找不到路径,因为它们是已重命名的路径。不知道如何解决这个价值百万美元的问题?

控制器:

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;
}
4

1 回答 1

1

由于您刚刚重命名./uploads/$target_keys./uploads/$new_dirs_keys,因此您不应该尝试这样做opendir("./uploads/$target_keys"),而是opendir("./uploads/$new_dirs_keys").

于 2012-06-13T21:04:43.970 回答