title: PHP script to copy a file from 1 FTP to another FTP
body: <p>I would like to copy a file (eg. MYFILE.csv) from <strong>FTP 'SOURCE'</strong> to <strong>FTP 'TARGET'</strong>. What type of command would you recommend for a <strong>script in php</strong>?</p>
  
  <p>I have tried this but it didn't work.</p>
  
  <pre><code>&lt;?php
  $server = 'ftp.TARGET.com' ;//address of ftp server
  $user_name = 'USER_TARGET'; // Username
  $password = 'PASSWORD_TARGET'; // Password
  
  $source = 'MYFILE.csv'; 
  $dest = '/in/MYFILE.csv';
  $mode='FTP_ASCII'; 
  
  // set up basic connection
  $connection = ftp_connect($server) ;
  
  // login with username and password
  $login_result = ftp_login($server, $user_name, $password);
  
  // upload a file
  if (ftp_put($connection, $dest, $source, $mode)) {
   echo "successfully uploaded $source\n";
  } else {
   echo "There was a problem while uploading $source\n";
  }
  
  // close the connection
  ftp_close($connection);
  ?&gt;
  </code></pre>
  
  <p><strong>=> The php script will be hosted in a folder on FTP A.
  Thank you for your guidance.</strong></p>