I have a function that I use to prompt CSV files for download. However, the filename fails to complete in Mozilla browser but works well with Chrome. For instance, if the file name should be F1_Open_marksheet.csv, Mozilla will prompt the download as F1 (missing the rest of the file name and extension. Could it be that my code is buggy?
<?php
function pushDownloadFile($filename){
header('Content-Description: File Transfer');
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename='.$filename);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($filename));
ob_clean();
flush();
readfile($filename);
unlink($filename);
}
?>