1
我想要一個文件MYFILE.csv
到遠程FTP。以下是腳本。連接部分工作,但不是文件上傳。我收到「上傳時出現問題」消息。PHP腳本將文件上傳到FTP
謝謝你的幫助。
<?php
$server = 'ftp.website.com' ;//Address of ftp server
$user_name = 'MYUSERNAME'; // Username
$password = 'MYPASSWORD'; // Password
$source_file = '/home/MYFILES.csv';
$dest = '/in/';
// set up basic connection
$connection = ftp_connect($server, 21) or die("Couldn't connect to $ftp_server");
echo "can connect";
echo "<br />";
// login with username and password
ftp_login($connection, $user_name, $password) or die("Cannot login");
echo "can login";
echo "<br />";
// upload a file
if (ftp_put($connection, $dest, $source_file, FTP_BINARY))
{ echo "successfully uploaded \n";}
else
{ echo "There was a problem while uploading \n";}
// close the connection
ftp_close($connection);
?>