title: warning feof() expects parameter 1 to be resource
body: <p>My error logs are getting out of control with the two below errors</p>
  
  <pre><code>warning feof() expects parameter 1 to be resource
  </code></pre>
  
  <p>and</p>
  
  <pre><code>warning fread() expects parameter 1 to be resource
  </code></pre>
  
  <p>The bit of code responsible is</p>
  
  <pre><code>&lt;?php
      $file = '../upload/files/' . $filex;
      header("Content-Disposition: attachment; filename=" . urlencode($file));
      header("Content-Type: application/force-download");
      header("Content-Type: application/octet-stream");
      header("Content-Type: application/download");
      header("Content-Description: File Transfer");
      header("Content-Length: " . filesize($file));
      flush(); // this doesn't really matter.
  
      $fp = fopen($file, "r");
      while (!feof($fp)) {
          echo fread($fp, 65536);
          flush(); // this is essential for large downloads
      }
      fclose($fp);
  ?&gt; 
  </code></pre>
  
  <p>I used this code for header downloads but its freaking out right now - before anyone asks what I have tried, I tried google but still don't fully understand the error message.</p>