title: File size will not display on PHP download script during file download
body: <p>I am using a PHP script to download a file when you go to a page, but I can't set it up so that when a person downloads the file, it will show the file size (mine shows "unknown time remaining"). I've looked around on Google and can't find out how to make file sizes show up for me, because according to all these scripts I'm doing it right. I have echo'd the filesize to make sure that the script is reading the file properly, and it returns the correct file size in bytes.</p>
  
  <pre><code>$file = 'audio/song.mp3';
  
  if(file_exists($file)) {
      header('Content-description: File Transfer');
      header('Content-type: application/force-download');
      header('Content-disposition: attachment; filename="' . $songname . '_' . $filetype . '.' . $ext . '"');
      header('Content-Transfer-Encoding: binary');
      header('Expires: 0');
      header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
      header('Pragma: public');
      header('Content-Length: ' . filesize($file));
      ob_clean();
      flush();
      readfile($file);
      exit;
  }
  else {
      die;
  }
  </code></pre>
  
  <p>Thanks in advance.</p>
  
  <hr>
  
  <p>Thank you, that disabling mod_deflate worked.</p>
  
  <p>In case anyone stumbles here and needs to figure out how to fix it, add this to your .htaccess.</p>
  
  <pre><code>    # for URL paths that begin with "/foo/bar/"
  SetEnvIf Request_URI ^/foo/bar/ no-gzip=1
  
  # for files that end with ".py"
  &lt;FilesMatch \.py$&gt;
      SetEnv no-gzip 1
  &lt;/FilesMatch&gt;
  </code></pre>