title: Force download from external server and rename
body: <p>I need help with a problem in a tool that Im developing.</p>
  
  <p>I need to download an external file and rename it, but without using readfile(), file_get_contents() or fread() (the files are too big to read them on the server  and download it again at visitor PC). </p>
  
  <p>I have tried first with:</p>
  
  <p>Code:</p>
  
  <pre><code>header("Location: http://www.example.com/example_download.zip");
  </code></pre>
  
  <p>It works for the download, but no for the example_download.zip rename.</p>
  
  <p>So I have tried with readfile():</p>
  
  <p>Code:</p>
  
  <pre><code>header("Content-Disposition: attachment; filename="example_download_2.zip"\n\n");
  header("Content-Type: application/force-download");
      readfile("http://www.example.com/example_download.zip");
      exit;
  </code></pre>
  
  <p>With the above code it works well, downloading the remote file first on the server, renaming it and after sending it to the visitor with the new name, but the resources usage of this process is very high, and also the bandwidth usage.</p>
  
  <p>So I'm looking for a way to generate a force-download of an external file, renaming it on the fly and generating a download with the new name but downloading directly from the source. I'ts possible?</p>
  
  <p>Thanks in advance
  Regards</p>