title: PHP readfile doesn't work, but only for 20+ meg files
body: <p>Small script, being used to send one of two .pdf files to the user based on the get string:</p>
  
  <pre><code>if ($fileToSend == "bigone") { 
     $filename = "largefile.pdf";
     $header = "application/pdf";
  } else if ($fileToSend == "smallone") { 
     $filename = "smallfile.pdf";
     $header = "application/pdf";
  }
  if (file_exists('d/' . $filename)){
      header('Content-type: ' . $header);
      header('Content-disposition: attachment; filename=' . $filename);   
      readfile('d/' . $filename);
  } else { 
      echo('No good');
  }
  </code></pre>
  
  <p>Both files d/smallfile.pdf and d/largefile.pdf exist. smallfile.pdf is about 5megs. largefile.pdf is about 25megs. </p>
  
  <p>sendFile.php?fileToSend=smallone works. </p>
  
  <p>sendFile.php?fileToSend=bigone doesn't work; in FF, it says </p>
  
  <p>File not found
  Firefox can't find the file at [url]/sendFile.php?fileToSend=bigone</p>
  
  <p>There are no filename errors. </p>
  
  <p>I've tried </p>
  
  <ul>
  <li>Adding flush(); prior to the readfile; this causes the download file dialogue box to appear, but then serves a 0 byte file</li>
  <li>Adding flush(); prior to the readfile, and adding header('Content-Length: ' . filesize('d/' . $filename)); - this works successfully, but takes close to 2 minutes to process (ie, once I hit the URL, nothing happens for close to 2 minutes, and then the dialogue box appears with the actual file to download in it correctly). </li>
  </ul>
  
  <p>Any help would be much appreciated. 
  Jon</p>