0
<?php
$local_file = "/home/zzh/Desktop/1.txt";
$server_file = "/var/www/helpdesk/1.txt";
$ftpserver = "xxx.xxx.xxx.xx";
$port = xx;
$conn_id = ftp_connect($ftpserver,$port) or die('can\'t connect to ftp'); 
$ftpname="xxx";
$ftppass = "xxx";
ftp_login($conn_id, $ftpname, $ftppass); 

if (ftp_get($conn_id, $local_file, $server_file, FTP_ASCII)) {
echo "Successfully written to $local_file\n";
} else {
echo "There was a problem\n";
}
// close the connection
ftp_close($conn_id);
?>

我想用这个php登录ftp服务器下载1.txt来替换桌面上的1.txt,但是好像不行,我用的是ubuntu。需要帮助。

附言。我可以成功连接到ftp。

4

1 回答 1

0

It should replace it if IIRC.

If not, why not do

if ( file_exists($local_file) ) unlink($local_file)

This would go before your ftp_get procedure.

于 2013-01-25T05:42:14.013 回答