title: Header add Content-Disposition "attachment" causes Internal Server error
body: <p>As the builtin browser of my ebook-reader (Sony PRS-T1) is quite stupid and wants to open .epub files as text-files instead of downloading them, I tried to force the browser to download the .epub files with this .htaccess file:</p>
  
  <pre><code>&lt;FilesMatch "\.(?i:epub)$"&gt;
    ForceType application/octet-stream
    Header add Content-Disposition "attachment"
  &lt;/FilesMatch&gt;
  </code></pre>
  
  <p>However, this causes an internal server error:</p>
  
  <blockquote>
    <p>Internal Server Error</p>
    
    <p>The server encountered an internal error or misconfiguration and was
    unable to complete your request.</p>
    
    <p>Please contact the server administrator, webmaster@localhost and
    inform them of the time the error occurred, and anything you might
    have done that may have caused the error.</p>
    
    <p>More information about this error may be available in the server error
    log.</p>
  </blockquote>
  
  <p>When I leave out <code>Header add Content-Disposition "attachment"</code> there is no error - however, the browser wouldn't download the file :(</p>
  
  <p>Am I doing something wrong? Where does the Internal Server error come from?</p>
  
  <p><strong>[EDIT 2013-04-11]</strong></p>
  
  <p>I just earned the "popular question-badge" for this thread, which reminded me of adding some information.</p>
  
  <p>I finally managed to force a download on Sony's PRS-T1 browser with the following php-function</p>
  
  <pre><code>function startDownload($path, $mimeType) {
  if(!file_exists($path)) {
  // File doesn't exist, output error
  exit('file not found');
  } else {
  $size = filesize($path);
  $file = basename($path);
  
  // Set headers
  header("Pragma: public"); // required
  header("Expires: 0");
  header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  header("Cache-Control: private",false); // required for certain browsers
  header("Content-Description: File Transfer");
  header("Content-Disposition: attachment; filename=\"$file\"");
  header("Content-Type: $mimeType");
  header("Content-Transfer-Encoding: binary");
  header("Content-Length: $size");
  // Read the file from disk
  readfile($path);
  }
  
  exit();
  }
  </code></pre>
  
  <p>Hope that helps somebody one day.</p>