title: How to stream a file I get from an FTP without storing it locally?
body: <p>I need to serve to my web portal enduser a file stored on a FTP server.</p>
  
  <p>I create a local temp file, I download the FTP's file in my temporary file, and when it finish I send it with Symfony's file HTTP response:</p>
  
  <pre><code>$tempPath = tempnam(sys_get_temp_dir(), 'ftp');
  
  $tempFile = fopen($tempPath, 'a+');
  
  $log = "myLog";
  $pass = "myPwd";
  
  $conn_id = ftp_connect('my.ftp.server');
  $ftp_login = ftp_login($conn_id, $log, $pass);
  
  ftp_fget($conn_id, $tempFile, $path, FTP_ASCII, 0);
  ftp_close($conn_id);
  
  fclose($tempFile);
  
  return $app-&gt;sendFile($tempPath, 200, array('Content-Type' =&gt; 'application/force-download', 'Content-disposition' =&gt; "attachment; filename=myFile.zip"));
  </code></pre>
  
  <p>It works but I would do better (ensure temp file deletion, improve performance, ...)</p>
  
  <p>I see that Symfony provides HTTP streamed response helper, so I imagine to send the FTP's file without to store it on web server's hard drive disk.</p>
  
  <p>To get it I think I need to connect <code>ftp_fget()</code> function (or other FTP function) to a PHP function that can output it to <code>php://output</code> or standard output (I don't really know this PHP scope).</p>
  
  <p>I find the <code>readfile()</code> function but it take the filename as argument, not a resource like <code>ftp_fget()</code> need... <strong>Is there other function compatible with fget_fget or other way to do it</strong>?</p>