title: How to view pdf file in browser using PHP Codeigniter Framework
body: <pre><code>function view_file() {
          $id = $this-&gt;uri-&gt;segment(3);
          $file = realpath('./uploads/'.$id);
          header('Content-Type: application/pdf');
          @readfile($file);
      }
  </code></pre>
  
  <blockquote>
    <p>this is my controller there is no error but it automatically download the pdf file and it didn't view in web browser</p>
  </blockquote>