I would like to a file MYFILE.csv to a remote FTP. Below is the script. The connection part works but not the file upload. I get the "There was a problem while uploading" message.
Thank you for your help.
<?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);
?>