我正在将重命名功能设置为dirs的crud系统的一部分,并设置一个进程来重命名uploads目录的子目录,并且重命名过程正在工作意味着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;
}
答案 0 :(得分:1)
由于您刚刚将./uploads/$target_keys
重命名为./uploads/$new_dirs_keys
,因此您不应该尝试opendir("./uploads/$target_keys")
,而应opendir("./uploads/$new_dirs_keys")
。