<?php
error_reporting(E_ALL);
set_time_limit(300);//for setting
$path='/PickUpOld';
$ftp_server='xxxxxx.com';
$ftp_server_port="xx";
$ftp_user_name='xxxxxxx';
$ftp_user_pass="xxxxxxxx";
// set up a connection to ftp server
$conn_id = ftp_connect($ftp_server, $ftp_server_port);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
$ps = ftp_pasv($conn_id, true);
// check connection and login result
if ((!$conn_id) || (!$ps)) {
echo "Fail</br>";
} else {
echo "Success</br>";
// enabling passive mode
ftp_pasv( $conn_id, true );
// get contents of the current directory
$contents = ftp_nlist($conn_id, $path);
// output $contents
$local_file = 'rana.php';
$server_file = 'PickUpOld/test.php';
if ( ftp_get( $conn_id, $local_file, $server_file, FTP_BINARY ) ) {
echo "WOOT! Successfully written to $local_file\n";
}
else {
echo "Doh! There was a problem\n";
}
}
// close the FTP connection
ftp_close($conn_id);
?>
我正在尝试将一个服务器的文件复制到另一个服务器。此脚本在localhost上正常工作,但不在Live服务器上工作。 请在我做错的地方分享您的想法。
谢谢,