title: Download file php in the server
body: <p>in the localhost i get everything perfect but when i upload it to the server i get this error</p>
  
  <p>Warning: Cannot modify header information - headers already sent by(
  hier is my code</p>
  
  <pre><code>    &lt;?php
  
  function download($file){
      $dir = './download/';
      $path = $dir.$file;
      if(!file_exists($path)){
          die('Error');
      }else{
          header('Content-Description : File Transfer');
          header('Content-Disposition : attachment; filename='.basename($path));
          header('Content-Type: application/octet-stream');
          header('Expires: 0');
          header('Cache-Control: must-revalidate');
          header('Pragma: public');
          header('Content-Length: ' . filesize($file));
          ob_clean();
          ob_start();
          flush();
          readfile($path);
          exit;
      }
  }
  if (isset($_GET['download'])) {
      if (!empty($_GET['download'])) {
          $file = $_GET['download'];
          download($file);
      }
  }
   ?&gt;
  
  &lt;a class="download-template" href="example.php?download=Modern.rar"&gt;Download&lt;/a&gt;
  </code></pre>