title: Require explicit FTP over TLS with PHP
body: <p>I'm trying to upload file to ftp with php. Only requirement from server's admin were Encryption should be <code>Require explicit FTP over TLS</code>. And that's it but I'm getting error <code>Warning: ftp_fput() [function.ftp-fput]: Can't open data connection.</code>. I manage to connect(in passive mode), but it fails to upload with any function(<code>ftp_put</code>, <code>ftp_nb_put</code>, <code>ftp_fput</code>). Error is the same all the times. I'm trying following code:</p>
  
  <pre><code>$host = 'ftps.someserver.net';
  $user = '****';
  $pass = '****';
  $filename = "somefile.txt"
  
  
  $dest_file = $filename;
  $source_file = dirname(__FILE__) . '/' . $filename;
  
  $fp = fopen($source_file, 'r');
  
  $ftp = ftp_ssl_connect($host, 21, 180);
  
  
  if (ftp_login($ftp,$user,$pass)) {
  
      var_dump(ftp_pasv($ftp, true)); // gives me true
      // # first way
      // ftp_put($ftp, $dest_file, $source_file, FTP_BINARY);
  
      // # second
      // $ret = ftp_nb_put($ftp, $dest_file, $source_file, FTP_BINARY, FTP_AUTORESUME);
  
      // while (FTP_MOREDATA == $ret)
      // {
      //   $ret = ftp_nb_continue($ftp);
      // }
  
      // # third
      if (ftp_fput($ftp, $dest_file, $fp, FTP_ASCII)) { // I was trying FTP_BINARY and FTP_ASCII.
          echo "Successfully uploaded\n";
      } else {
          echo "There was a problem while uploading\n";
      }       
  }
  ftp_close($ftp);
  fclose($fp);
  </code></pre>
  
  <p>It works fine with my own ftp, that does not asks for explicit TLS. Any ideas would be appreciated. </p>