title: downloading large files while hiding the source address in php
body: <p>I need to hide external file links from the user.
  The user clicks the download button which refers to my function in which the file is download and return to the client, the problem is I don't know what extension of the downloaded file is</p>
  <p>So I download the file via &quot;get_file_contents&quot; and read the original file name from the header but it is not suitable for large files</p>
  <p>I originally used readfile but there were cases that some files were zipped</p>
  <p>current code</p>
  <pre><code>    $sUrl = ... external url;
      $sFileName = '';
      $context = stream_context_create();
      $mResult = file_get_contents($sUrl, false, $context);
      foreach($http_response_header as $header) {
          if (strpos($header, 'Location:') !== false) {
              $sFileName = basename(trim(str_replace('Location:', '', $header)));
              break;
          }
      }
      header(&quot;Content-Description: File Transfer&quot;);
      header(&quot;Content-Type: application/octet-stream&quot;);
      header(&quot;Content-Disposition: attachment; filename={$sFileName}&quot;);
      echo $mResult;
      exit();
  </code></pre>
  <p>How can I hide the external link to the downloaded file and at the same time return very large files to the client?</p>