title: Receiving empty file when downloaded
body: <p>I'm trying to download files form server using PHP by passing the path and file name through URL, like this:</p>
  
  <pre><code>&lt;a class="downloadBtn" style="float:left;" href="download_file.php?folder=&lt;?php echo $codrepresentante.'&amp;file='.$nomeArquivo ?&gt;" &gt;download&lt;/a&gt;
  </code></pre>
  
  <p>Then I receive this PHP file:</p>
  
  <pre><code>&lt;?php
  
  $fileName = $_GET['file'];
  $coisa=urldecode($fileName);
  
  $path= "http://localhost/portal/boletos/".$_GET["folder"];
  $filePath = $path.'/'.$coisa;
  echo "caminho: ".$filePath;
  
  if(file_exists($filePath)){
      // Define headers
  
      header("Content-Description: File Transfer");
      header("Content-Transfer-Encoding: binary");
      header("Content-Disposition: attachment; filename=".$coisa);
      header('Content-Type: application/octet-stream');
      header('Cache-Control: must-revalidate');
      header('Content-Length: ' . filesize($coisa));
      ob_clean();
      flush();
      // Read the file
      echo readfile($filePath);
      exit;
  } else {
      echo 'The file does not exist.';
  }
  ?&gt;
  </code></pre>
  
  <p>But I always get empty files or the <code>The file does not exist</code> response.</p>
  
  <p>I got the <code>$filePath</code> variable  and used in the browser to see if the path was wrong, but it worked, so the path is correct.</p>
  
  <p>Could someone help me by indicating where I made a mistake?</p>