<?
$ftp_server = "name.info";
$ftp_user = "user";
$ftp_pass = "pass";
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass))
{
ftp_chdir($conn_id, 'public_html/');
$contents = ftp_nlist($conn_id, '-la .');
print_r($contents);
foreach($contents as $line){
$file = preg_split('@\[email protected]', trim($line));
$name = $file[8];
$size = $file[4];
$mode = $file[0];
if(substr($mode, 0, 1) == '-'){
//file
$fd = fopen('d/'.$name, 'w');
ftp_fget ($conn_id, $fd, $name, FTP_BINARY);
fclose($fd);
}else{
//dir
}
}
}
else
die ("Couldn't connect as $ftp_user\n");
?>
我想获取所有public_html文件夹。如果我能压缩它,那将是完美的。我试图写一些东西,但它不会复制这些文件。我错过了什么?来自FTP的Zip文件夹
什么是行不通的? – thetaiko 2012-02-16 18:31:41
@thetaiko:它不会将文件复制到我的目录。 – 2012-02-16 18:32:32
@hey ...对。什么,具体而言,不起作用。连接?登录? fget?这里有很多函数在成功或失败时返回布尔值。 – thetaiko 2012-02-16 18:45:39