【发布时间】:2012-01-28 03:26:42
【问题描述】:
我的代码出现以下错误:
警告:
[function.rename]:设备或资源忙于
if ($handle = opendir($temp_images)) {
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
if ($file == $file) {
}
$path = '';
$dir_handle = opendir($path);
chdir($path);
$oldfile = $path.$file ;
$newfile = $path.preg_replace('/[\\&\\%\\$\\ ]+/', '-', $file); // replace &%$ with a -
if(FALSE == rename($oldfile, $newfile))
{
}
}
closedir($handle);
}
有什么问题,我该如何解决?
【问题讨论】:
-
仔细检查文件名。看起来它们不正确。
-
文件名在 /temp-uploaded/ 很好
-
你有两个文件名,都应该没问题。你没有透露他们的全名,所以我不能告诉你他们好不好。我只能说当文件名错误/指向错误时会发生此错误。
-
所有文件名都在 /home/therealf/public_html/temp-uploaded/ $oldfile, $newfile 文件名在同一目录中
-
只需将新旧文件名完整添加到您的问题中。你能在 shell 中执行重命名操作吗?