title: curl get remote file and force download at same time
body: <p>I'm trying to get a remote file and force download it to user at the same time.
  I can't paste the code ,the code is too long . but the curl function works ,but the problem is it doesn't out put anything till it gets the remote file first then it force downloads it to user.</p>
  
  <p>I use this to tell curl to return a callback </p>
  
  <pre><code>curl_setopt($ch, CURLOPT_READFUNCTION, 'readCallback');
  </code></pre>
  
  <p>now in my readCallback function I do this :</p>
  
  <pre><code>function readCallback($curl, $stream, $maxRead){
      $read = fgets($stream, $maxRead);
      echo $read;
      return $read;
  }
  </code></pre>
  
  <p>but it doesn't return anything it just waits till fetching remote file is finished.</p>