title: readfile() method prints file instead of downloading
body: <p>I want to download a file using PHP from an absolute path using the header() and readfile() methods. It used to work before, but doesn't anymore.</p>
  
  <p>I've tried changing the Content-type, but nothing worked.</p>
  
  <pre class="lang-php prettyprint-override"><code>$p = $_GET['plugin'];
  $v = $_GET['version'];
  if (isset($p) &amp;&amp; isset($v)) {
      if (in_array($p, getPlugins($_SESSION['username']))) {
          $url = '/home/uploads/' . $p . '/' . $v . '.jar';
          header('Content-Description: File Transfer');
          header("Content-type: application/java-archive");
          header('Content-Disposition: attachment; filename="' . $p . ' ' . $v . '.jar"');
          header('Expires: 0');
          header('Cache-Control: must-revalidate');
          header('Pragma: public');
          header('Content-length: ' . filesize($url));
          readfile($url);
          //header('Location: plugins.php');
          exit();
      }
  }
  </code></pre>
  
  <p>It should download the jar file that should be named something like "MyPlugin Snapshot-1.0.0.jar". Instead, it prints the whole jar file to the page (see image)</p>
  
  <p><a href="https://i.stack.imgur.com/PNXYR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PNXYR.png" alt="enter image description here"></a></p>