title: php : Warning: ftp_put(): Could not open data connection to port xxxxxx: Connection timed out
body: <p>I am trying to copy files from server A(Domain A) to server B(Domain B).</p>
  
  <p>First i had tried to connect through</p>
  
  <pre><code>ftp_connect( "ftp.ServerA.Com", 21 );
  </code></pre>
  
  <p>but it gives error</p>
  
  <pre><code>"Clear texts are not allowed"
  </code></pre>
  
  <p>so i had changed with </p>
  
  <pre><code>ftp_ssl_connect( "ftp.ServerA.Com", 21 );
  </code></pre>
  
  <p>its connect perfectly.</p>
  
  <p>not the problem is : when i am trying to use</p>
  
  <pre><code>ftp_put($conn_id, $remote_file, $file, FTP_ASCII)
  </code></pre>
  
  <p>it creates a file on ServerB but it contains nothing, in terms of file size it always shows 0 KB. and it process a lot of time and at the end it returns with below line :</p>
  
  <pre><code>ftp_put(): Could not open data connection to port xxxxxx: Connection timed out.
  </code></pre>
  
  <p>i asked my hosting provider they suggest me to use "ftpes" instead of "ftp".</p>
  
  <p>i searched alot in google but nothing happened . so can anyone!</p>
  
  <h2><strong>Edit</strong></h2>
  
  <p>Full code : </p>
  
  <pre><code>&lt;?php 
      $settings = array(
          'host'    =&gt;    'ftp.XXXX.in',              // * the ftp-server hostname
          'user'    =&gt;    'XXXX',                 // * ftp-user
          'pass'    =&gt;    'XXXX',                 // * ftp-password
      );
  
  
      $connection = @ftp_ssl_connect( $settings['host'], 21 );
  
      $login = ftp_login( $connection, $settings['user'], $settings['pass'] );
      ftp_pasv($connection, true) or die("Cannot switch to passive mode");        
      if ( !$connection || !$login ) {
          die('Connection attempt failed, Check your settings');
      }
      if( @ftp_put( $connection, "text.txt", "test.txt", FTP_BINARY ) ) 
          echo "done";
      else
          echo "not";
      ftp_close($connection);
  </code></pre>
  
  <p>?></p>