title: PHP forces PDF file download even though I'm using Content-Disposition: inline
body: <p>I'm trying to display a PDF in the browser if possible--and I know I can do this in Chrome, which is what I'm testing in. The trouble is, every time I try, it prompts a download instead.</p>
  
  <p>I'm using PHP sessions, so I know there are some extraneous headers being sent, so I called <code>header_remove()</code> to reset everything.</p>
  
  <p>I call this function to show the PDF:</p>
  
  <pre><code>&lt;?php
  // For demonstrative purposes
  session_start();
  
  if (!isset($_SESSION['auth'])) {
      header('Location: login.php');
      die;
  }
  
  /*
   * void viewPDF (Report $report)
   * Outputs the PDF of the report
   */
  function viewPDF ($report) {
          // Tell the browser we are going to serve a PDF file.
      $file = dirname(__FILE__).'/../reports/'.$report-&gt;id.'.pdf';
          // The location of the PDF
      if (!file_exists($file)) {
          die ('The PDF does not exist.');
              // Somehow the file does not exist.
      }
  
      header_remove();
          // I'm using PHP sessions, so remove the headers
          // automatically set that might break something.
      header('Content-Disposition: inline;filename='.$report-&gt;id.'.pdf');
      header('Content-Transfer-Encoding: binary');
      header('Content-Type: application/pdf');
      header('Content-Length: '.filesize($file));
      readfile($file);
          // Serve the report PDF file from the reports
          // repository.
      die;
          // Any whitespace could corrupt the PDF, so be extra
          // sure nothing else gets printed.
  }
  
  // For demonstrative purposes:
  $report = new StdClass;
  $report-&gt;id = 1;
  viewPDF($report);
  ?&gt;
  </code></pre>
  
  <p>These are the headers being sent:</p>
  
  <pre><code>Date: Tue, 08 Oct 2013 18:41:32 GMT
  Server: Apache/2.2.22 (Win32) PHP/5.4.15
  Content-Type: application/pdf
  Content-Transfer-Encoding: binary
  Content-Disposition: inline;filename=1.pdf
  Connection: Keep-Alive
  Keep-Alive: timeout=5, max=100
  Content-Length: 73464
  </code></pre>
  
  <p>It's still prompting a download though. Once it downloads, I can open it in Adobe Reader just fine.</p>
  
  <p>Am I missing something?</p>
  
  <p>Thanks.</p>