title: PHP ftp_put fails with "Warning: ftp_put (): PORT command successful"
body: <p>File is created on the FTP server, but its always 0 bytes large. Please give me a solution so that the file upload will working success.</p>
  <p>I keep getting this warning:</p>
  <blockquote>
  <p>Warning: ftp_put (): PORT command successful in C: \ xampp \ htdocs \ mailing \ teskirim-file-simpan2.php on line 30<br />
  FTP upload has failed!</p>
  </blockquote>
  <p><img src="https://i.stack.imgur.com/Htila.jpg" alt="enter image description here" /></p>
  <p>My script is:</p>
  <pre><code>&lt;?php
  $ftp_server = &quot;********&quot;;
  $ftp_serverpath = &quot;ftp.&quot;.$ftp_server;
  $ftp_user_name = &quot;********&quot;;
  $ftp_user_pass = &quot;***********&quot;;
  $email_dir = &quot;*******@*********&quot;;
  
  $nyambungkeftp = ftp_connect($ftp_server);
  if (false === $nyambungkeftp) {
      throw new Exception('Unable to connect');
  }
  
  $loggedInnyambungkeftp =
      ftp_login($nyambungkeftp,  $ftp_user_name,  $ftp_user_pass);
  if (true === $loggedInnyambungkeftp) {
      echo 'Success!';
  } else {
      throw new Exception('Unable to log in');
  }
  
  if ((!$nyambungkeftp) || (!$loggedInnyambungkeftp)) { 
          echo &quot;FTP connection has failed!&quot;;
          echo &quot;Attempted to connect to $ftp_server for user $ftp_user_name&quot;; 
          exit; 
      } else {
          echo &quot;Connected to $ftp_server, for user $ftp_user_name&quot;;
      }
  
  // upload the file
  $dest = 'detectip.txt';
  $source = 'C:\xampp\htdocs\persuratan\file2\detectip.txt';
  
  echo $dest;
  echo $source;
  $upload = ftp_put($nyambungkeftp, $dest, $source, FTP_ASCII); 
  
  
  // check upload status
  if (!$upload) { 
          echo &quot;FTP upload has failed!&quot;;
      } else {
          echo &quot;Uploaded $source_file to $ftp_server as $destination_file&quot;;
      }
  
  // close the FTP stream 
  ftp_close($nyambungkeftp); 
  
  ?&gt;
  </code></pre>