title: PHP - Force download or view in browser depending on file type
body: <p>I am using the following headers to force a download but I need to try and have the browser display certain files like PDF's and JPG's if that is the file type, finding the exntension is easy enough but how can I alter these headers to open the file in the browser?</p>
  
  <pre><code>header("Content-Description: File Transfer");
  header("Content-type: application/octet-stream");
  $header="Content-Disposition: attachment; filename=".$filename.";";
  header($header);
  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");
  </code></pre>