PHP重命名(<;from>;,<;to>;)给出警告:";是一个目录;


PHP rename(<from>, <to>) gives warning: "Is a directory"

我有以下功能:

function move($currentPath, $newPath)
{
    if (!$this->_createFolder($newPath))
        return false;
    if (!rename($currentPath, $newPath))
        return false;
    return true;
}

其中_createFolder()检查目录是否存在,如果不存在,则创建它。我一直收到以下警告:

"重命名(/home/user/folder/folder/app/webroot/ig/listings/incomplete/15/0/picture1.png,/home/user/folder/older/app/webaroot/ig/listings/130/picturel.png):是一个目录"

文件已成功复制到第二个目录,但未从第一个目录中删除。rename()返回false,并给出此警告。我以为这可能是有权限的东西,但在尝试了一堆东西后,我似乎无法弄清楚。

如有任何帮助,我们将不胜感激。

您的代码正在使用$newpath 创建一个文件夹

if (!$this->_createFolder($newPath))
        return false;

则CCD_ 2变为目录。