我只是想用ftp替换一个文件,两个目的地都在同一服务器上
新文件:/home/srv/dev_html/test.php
旧文件:/home/srv/public_html/test.php
$new = "/home/srv/dev_html/test.php";
$old = "/home/srv/public_html/test.php";
$tmp = explode("/",$new);
$newfile = end($tmp);
$newdir = str_replace($newfile,"",$new);
ftp_chdir($conn_id,$newdir); //try changing directory
ftp_put($conn_id, $old, $newfile, FTP_ASCII);
ftp_chdir上出现错误,表示ftp_chdir(): Can't change directory to /home/srv/dev_html/: No such file or directory
我已经用file_exists()
确认了它的存在
这是否意味着你不能使用绝对路径
如果没有,还有什么更好的方法?
感谢
使用ftp_rename函数代替
ftp_rename($conn_id, $old, $newfile);
请在此处查看详细信息:http://php.net/manual/en/function.ftp-rename.php