I have an excel file which can be downloaded..for example NAME.xlsx well it works in firefox but in webkit(safari/chrome) it appends to the name also the extension .xhtml so then name it will be NAME.xlsx.html it should be ONLY .xlsx
Here you have my headers:
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save($root.'/application/to_excel/KSW.xlsx');
$this->getResponse()->setHeader('Content-type', 'application/download', true);
$this->getResponse()->setHeader('Content-type', 'application/octet-stream', true);
$this->getResponse()->setHeader('Content-type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', true);
$this->getResponse()->setHeader('Content-disposition', 'attachment;filename='.basename($root.'/application/to_excel/KSW.xlsx').'', true);
$this->getResponse()->setHeader('Cache-Control', 'max-age=0', true);
So what I'm doing wrong?
I've not had this function fail yet -- it works with all the Office 2007/2010 files that I've tried so far in Safari (Windows) and Chrome. The get_known_mime_types() function just returns a giant array of all the mime-types that my app supports -- just Google for the MIME types you need.
$file
is the actual path to the file on your host, and$name
is the file name that displays in the download (run/save) dialog. I've also given due credit to the place I got most of it from. Hope you have luck with it too: