title: PHP FTP upload not working
body: <p>What I'm trying to do is automaticly upload a zip-file through FTP using PHP, and then extract the zip-file as well. However first things first: I'm having trouble with uploading the zip-file using PHP's ftp_put function. This is my script:</p>
  
  <pre><code>// set up basic connection
  $conn_id = ftp_connect($ftp_server); 
  
  // login with username and password
  $login_result = ftp_login($conn_id, $user, $pass); //&lt;!--same as cPanel account user and pass?
  
  // check connection
  if ((!$conn_id) || (!$login_result)) { 
      echo "FTP connection has failed!";
      echo "Attempted to connect to $ftp_server for user $user"; 
      exit; 
  } else {
      echo "Connected to $ftp_server, for user $user";
  }
  
  // server &amp; file info
  $file = 'phpBB3.zip';
  $ftp_root = '/public_html/';
  $site_root = $_SERVER['DOCUMENT_ROOT'].'/scripts/';
  
  // &gt;&gt;&gt;HERE&lt;&lt;&lt;
  // upload the file
  // &gt;&gt;&gt;HERE&lt;&lt;&lt;
  $upload = ftp_put($conn_id, $ftp_root .$file, $site_root . $file, FTP_BINARY);
  
  // check upload status
  if (!$upload) { 
      echo "FTP upload has failed!";
  } else {
      echo "Uploaded $file to $ftp_server as $file";
  }
  
  // unzip the uploaded file (from FTP?)
  $unzip = shell_exec("unzip {$file}"); //&lt;!-- how to do this through FTP uploaded files?
  
  // close the FTP stream 
  ftp_close($conn_id); 
  </code></pre>
  
  <p>What's happening here is that it (SOMETIMES) uploads A PART of the file ( always the same amount; like 900 kB ) and sometimes doesn't upload anything at all. It's as if the uploading process is interrupted by the rest of the script being executed while the uploading wasn't finished yet. Though I'm not sure if that's the cause of the problem.</p>
  
  <p>Though, it always gives me this error:</p>
  
  <blockquote>
    <p>Warning: ftp_put() [function.ftp-put]:
    Connecting to port 38694 in
    /home/quicksit/public_html/createacct.php
    on line 93</p>
  </blockquote>
  
  <p>Where the output port is always different and always larger than 20.000 ( like 30.000-50.000 ).</p>
  
  <p>Could anyone help me out on this?</p>
  
  <p>Thanks in advanced,
  Skyfe.</p>