title: Force download file with PHP giving empty file
body: <p>The end goal is for the user to download a .csv file. Right now I'm just testing trying to download a simple text file: test.txt. The only thing in this file is the word "test".</p>
  
  <p>Here is the HTML code for files_to_download.php</p>
  
  <pre><code>Test file: &lt;a href='test.php?file=test.txt'&gt;Test.txt&lt;/a&gt;
  </code></pre>
  
  <p>Code for test.php:</p>
  
  <pre><code>if(!(empty($_GET["file"])))
  {
      $file_name = $_GET["file"];
      $path = "path/to/file";
      $fullPath = $path . $file_name;
  
      if(ini_get('zlib.output_compression'))
        ini_set('zlib.output_compression', 'Off');
  
      header("Cache-Control: public");
      header("Content-Description: File Transfer");
      header("Content-Disposition: inline; attachment; filename=\"$file_name\"");
      header("Content-Type: text/plain");
      header("Content-Transfer-Encoding: binary");
      readfile($fullPath);
  }
  </code></pre>
  
  <p>I've tried variations of the headers above, adding more and removing others. The above seem to be the most common recommended on this site.</p>
  
  <p>I've also tried changing</p>
  
  <pre><code>header("Content-Type: text/plain");
  </code></pre>
  
  <p>to</p>
  
  <pre><code>header("Content-Type: text/csv");
  </code></pre>
  
  <p>and get same results: empty .txt or .csv file.</p>
  
  <p>The files are not empty when I open them directly (file browser) from the server. I've checked the permissions of the files and they're both 644, so the entire world can at least read the files. The directory is 777.</p>
  
  <p>Is there a configuration on the Apache server I need to specify that may not be or am I missing something above.</p>
  
  <p>Thanks for looking!</p>