title: PHP script to upload a file to a FTP
body: <p>I would like to a file <code>MYFILE.csv</code> 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.</p>
  
  <p>Thank you for your help.</p>
  
  <pre><code>&lt;?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 "&lt;br /&gt;";
  // login with username and password
  ftp_login($connection, $user_name, $password) or die("Cannot login");
  echo "can login";
  echo "&lt;br /&gt;";
  
    // 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);
  ?&gt;
  </code></pre>