2017-01-17 84 views
2

为什么我得到错误ftp_rename(): Rename folder/my_file: No such file or directory而文档说它应该是Returns TRUE on success or FALSE on failure.为什么ftp_rename会抛出一个php错误

而对于其他方法(如ftp_chdir)它说Returns TRUE on success or FALSE on failure. If changing directory fails, PHP will also throw a warning.

我做错了什么?

编辑

这里是我的代码:

$connection = ftp_connect('host', 21); 
    ftp_login($connection, 'username', 'password'); 
    ftp_pasv($connection, true); 

    $result = ftp_rename($connection, 'Out/efffs_v1.0.xml', 'folder/my_file'); 
    var_dump($result); 

输出我得到:

Warning: ftp_rename(): Rename folder/my_file: No such file or directory in MyScript.php on line 96 

没想到得到这个警告。

+2

你的脚本可能越来越为'回声$结果;' ,如果布尔值为false,则只有$ result不会是可打印的,因此您将看不到任何输出。尝试'var_dump($ result);'出于调试目的,或'echo $ result? “成功”:“失败”;'为人类可读的输出 – GordonM

+0

你是可怕的我得到'布尔(虚假)',但这仍然不能回答我的问题,得到警告预期的行为或文档不是最新的 –

+1

不幸的是,并非所有引发错误的函数都被正确记录。 –

回答

1

也许“文件夹/我的文件”的新文件夹路径中的“文件夹”不存在于您的服务器上。这可能是为什么ftp_rename函数失败。

你说得对,函数的文档(http://php.net/manual/en/function.ftp-rename.php)没有提到它会给出警告。

您可以提交错误报告缺少文件:https://bugs.php.net/report.php?bug_type=Documentation+problem&manpage=function.ftp-rename

您也可以留下字条该函数的文档页面:http://php.net/manual/en/function.ftp-rename.php

+0

谢谢。我确实报告了这个问题,现在它已经修复https://bugs.php.net/bug.php?id=73958 –

相关问题