//FTP文件上傳
$ftp_server = "192.168.0.222";到 // 你的FTP 地址
$FTP_user = "source";
$FTP_pass = "123456";
// set up a connection or dIE
$conn_id = ftp_connect($ftp_server,0) or dIE("Couldn't connect to $FTP_server");
//print_r($conn_id);
$login_result = ftp_login($conn_id, $ftp_user, $FTP_pass);
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $FTP_user_name";
exit;
} else {
echo "Connected to $ftp_server, for user $FTP_user_name";
}
// try to login
//$filename=date('Ymd').".XML";
//$source_file="user/XML/data/".$filename; //源地址 文件所在地址
$destination_file="temp/".$filename; //目標地址 文件要上傳的地址
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY) or dIE("Couldn't connect to $FTP_server");
FTP_quit($conn_id);
if (!$upload) {
echo "FTP upload has failed!";
} else {
echo "Uploaded $source_file to $FTP_server as $destination_file";
}
FTP_close($conn_id);