title: Unable to store file using PHP cURL, timeout
body: <p>I'm stuck trying to upload a file to a FTPS server. I'm getting all the time a timeout error. The file is created on destination FTPS but it's always empty.
  If I do use the same config on a FTP Server, it does work. Any thoughts what could be missing?
  PHP 7.2 / cURL 7.67.
  Here is a glimpse of the code :</p>
  <pre><code>$fp = fopen($filename, 'r');
  $ftp_server = 'ftps://'.$server.':'.$port.'/'.$filename; 
  $ch = curl_init(); 
  
  curl_setopt($ch, CURLOPT_URL, $ftp_server);
  curl_setopt($ch, CURLOPT_USERPWD,$username.':'.$passwd);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); 
  curl_setopt($ch, CURLOPT_TIMEOUT, 10); //timeout in seconds
  
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  curl_setopt($ch, CURLOPT_FTP_SSL, true);
  curl_setopt($ch, CURLOPT_USERAGENT, 'curl/7.67.0');
  curl_setopt($ch, CURLOPT_VERBOSE, true);
  curl_setopt($ch, CURLOPT_UPLOAD, 1);
  curl_setopt($ch, CURLOPT_INFILE, $fp);
  curl_setopt($ch, CURLOPT_INFILESIZE, filesize($filename));
  curl_setopt($ch, CURLOPT_STDERR, fopen('curl.txt', 'w+'));
  
  $output = curl_exec($ch);
  $error_no = curl_errno($ch);
  $error_msg = curl_error($ch);
  echo &quot;&lt;br&gt; error_no: &quot;.$error_no;
  echo &quot;&lt;br&gt; error msg :&quot;.$error_msg;
  curl_close($ch);
  fclose($fp);
  </code></pre>
  <p>curl echo</p>
  <pre><code>error_no: 28
  error msg :Operation timed out after 10003 milliseconds with 0 bytes received
  </code></pre>
  <p>curl.txt returns this...</p>
  <pre><code>...
  &gt; PWD
  &lt; 257 &quot;/&quot; is current directory.
  * Entry path is '/'
  * Request has same path as previous transfer
  &gt; EPSV
  * Connect data stream passively
  * ftp_perform ends with SECONDARY: 0
  &lt; 229 Entering Extended Passive Mode (|||45592|).
  *   Trying x.x.x.x:45592...
  * TCP_NODELAY set
  * Connecting to x.x.x.x (x.x.x.x) port 45592
  * Connected to destination.address.dns (x.x.x.x) port 990 (#0)
  &gt; TYPE I
  &lt; 200 Type set to I
  &gt; STOR test.txt
  * Operation timed out after 10010 milliseconds with 0 bytes received
  * Closing connection 0
  </code></pre>
  <p>Your advise would be very much appreciated.
  D</p>