<?php// define some variables $local_file = 'local.zip'; $server_file = 'server.zip';// connect to the ftp server $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);// try to download if (ftp_get($conn_id, $local_file, $server_file, ftp_BINARY)) { echo "Successfully written to $local_file\n"; } else { echo "There was a problem\n"; }// close the connection ftp_close($conn_id);?>
to: feel8(准备早起的鸟)我的代码也是这么写的,但是这样他就把文件从ftp服务器上下在到www服务器上了,并没有下在到客户机器上啊。如果直接用连接 <a href=ftp://ftpserver/path/>xxx</a>这样是可以实现了,但是这样的话,ftp服务器的密码就回看见了,
$local_file = 'local.zip';
$server_file = 'server.zip';// connect to the ftp server
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);// try to download
if (ftp_get($conn_id, $local_file, $server_file, ftp_BINARY)) {
echo "Successfully written to $local_file\n";
} else {
echo "There was a problem\n";
}// close the connection
ftp_close($conn_id);?>