title: php upload local file to ftp server
body: <p>i understand that the ftp_put method uploads a file from the local server computer to the ftp server but i have problems using it where when i try to execute a simple script like this:</p>
  
  <pre><code> &lt;?php
  // connect and login to FTP server
  $ftp_server = "ftp.example.com";
  $ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
  $login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);
  $file = "localfile.txt";
  // upload file
  if (ftp_put($ftp_conn, "serverfile.txt", $file, FTP_ASCII))
  {
  echo "Successfully uploaded $file.";
  }
  else
  {
  echo "Error uploading $file.";
  }
  
  // close connection
  ftp_close($ftp_conn);
  ?&gt;  
  </code></pre>
  
  <p>the operation is successfully done except for that the file uploaded to the my ftp server is always with zero byte size! </p>
  
  <p>also i tried to enable passive mode but it still uploads an empty file.</p>