title: Headers used to download file php
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5595485/php-file-download">php, file download</a>  </p>
  </blockquote>
  
  
  
  <p>I have files that are not in the web root that I need to make available for download. So I have a script that uses the below to download the file requested. The problem is, I everyfile downloaded is corrupt? The files are ok because if I use FTP to download, they open. Here are the headers passed:</p>
  
  <pre><code>header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
          header("Cache-Control: public"); // needed for i.e.
          header("Content-Type: " . $download[0]['mime']);
          header("Content-Disposition: attachment; filename=" .$download_file);
          header("Content-Transfer-Encoding: Binary");
          header("Content-Length:".filesize($attachment_location));
  
          readfile($attachment_location);
  </code></pre>