title: Downloading CSV file with PHP
body: <p>I am trying to download a CSV file with PHP but I can not make it to get the dialog box.
  I have changed the headers and used the readfile() function as shown <a href="http://php.net/manual/en/function.header.php" rel="nofollow">here</a></p>
  
  <p>This is my code:</p>
  
  <pre><code>$nodeId = 'something';
  $filename = "/var/www/dkar/ruralBroadband/ruralApp/rural/csvExports/$nodeId.csv";
  
  header('Content-type: text/csv');
  header('Content-disposition: attachment; filename ="report.csv"');
  readfile($filename);
  </code></pre>
  
  <p>** EDIT **</p>
  
  <p>Tried also with this as suggested:</p>
  
  <pre><code> header('Content-Disposition: attachment; filename="report.csv"');
   header('Content-Transfer-Encoding: binary');
   header('Content-Length: ' . filesize('report.csv'));
  </code></pre>
  
  <p>When I am checking the response in Firebug I can see the whole CSV file returned. Also the headers change into:</p>
  
  <pre><code>Content-Type    text/csv
  Content-disposition attachment; filename ="report.csv"
  </code></pre>
  
  <p>So I can not figure out why I dont get the dialog box to save the file.</p>