title: PHP Downloads Some Empty Files and Some Normally
body: <p>I have this code to download a Zip file from the server:</p>
  
  <pre><code>&lt;?php
  $path_parts = pathinfo($_GET['a']);
  $file_name  = $path_parts['basename'];
  $file_path  = 'temp/' . $file_name;
  
  if (file_exists($file_path)) {
      $size = filesize($file_path);
  
      header('Cache-Control: must-revalidate');
      header('Pragma: public');
      header("Content-Description: File Transfer");
      header("Content-Disposition: attachment; filename=$file_name");
      header('Expires: 0');
      header("Content-Type: application/zip");
      header("Content-length: $size");
      header("Content-Transfer-Encoding: binary");
  
      // read the file from disk
      readfile($file_path);
  }
  
  else
      echo 'File does not exists';
  ?&gt;
  </code></pre>
  
  <p>The files are stored in a <code>/temp</code> folder and the curious thing is that if I download a <code>TXT</code> file, it downlads OK, but if the file is a <code>ZIP</code> file then it downloads an empty file. Even if I change the extension of the <code>ZIP</code> file to <code>TXT</code> it still downloads empty, but any other file download just fine. What could be causing this behavior?</p>
  
  <p>In fact, it downloads any other file but the <code>ZIP</code> files in the folder.</p>