ftp下载ftp_get总报错找不到文件不知道什么原因,本地的路径不能写绝对路径么?
$remote_file = "2014-05-30_10-27-24-db.sql";
$local_file = "E:\\wamp\\www\\qc.sql";//(dirname(__FILE__))."/../../beifen/2014-05-29_17-11-00-db.sql";
//验证用户名和密码www.jb51 .net
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
//获取指定文件的大小
if ((!$conn_id) || (!$login_result)) {
echo '连接到ftp服务器失败';
exit;
} else {
//print_r(ftp_chdir($conn_id,$remote_file));
var_dump(ftp_pwd($conn_id));
//$a = (dirname(__FILE__))."/../../beifen/2014-05-29_17-11-00-db.sql";
var_dump(ftp_chdir($conn_id,"images"));
ftp_pasv ($conn_id,true); //返回一下模式,这句很奇怪,有些ftp服务器一定需要执行这句
if (ftp_get($conn_id, $local_file, $remote_file, FTP_BINARY)) {
echo "Successfully written to $local_file\n";
} else {
echo "There was a problem\n";
}
//关闭FTP连接
ftp_close($conn_id);
}
------解决方案--------------------
首先,把文件绝对路径打印出来看下是否正确, 到ftp 服务器上去确认是否真有此文件
如果有,确认 ftp 用户是否有权限访问此文件.