Some times your browser displays the contents of a file rather than giving the user an option to download the file. The code below forces the browser to show a download dialog to the user
<? $filename='files/export.csv'; $length=filesize($filename); header("Content-Type: application/csv"); header("Content-Length: ".$length); header('Content-Disposition: attachment;filename="'.$filename.'"'); echo file_get_contents($filename); ?>
More PHP tips