title: Headers for force download of apk file
body: <p>I'm doing a script that increases the counter for an APK file's download then sends the file to the browser for download.</p>
  
  <p>Here's what I have:</p>
  
  <pre><code>&lt;?php
      $file = "android.apk";
  
      function force_download($file){
      header("Pragma: public", true);
      header("Expires: 0"); // set expiration time
      header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
      header("Content-Type: application/force-download");
      header("Content-Type: application/octet-stream");
      header("Content-Type: application/download");
      header("Content-Disposition: attachment; filename=".basename($file));
      header("Content-Transfer-Encoding: binary");
      header("Content-Length: ".filesize($file));
      die(file_get_contents($file));
      }
  
      force_download($file
  </code></pre>
  
  <p>The problem is that with a browser like firefox, it downloads but it is like 'android.apk - 0 bytes'. So it essentially, it does not download the file's contents.</p>
  
  <p>What might I be doing wrong? A solution for this?</p>
  
  <p><strong>IMPORTANT</strong>: It has to work on mobile.</p>
  
  <p>);</p>