I have a little function, that creates .xls document(using PHPexcel) and then sends it to php://output. Then user download it.
Everything works fine, except that safari on
I have a similar problem and i solved it with the exit function (used parameter status).
In model:
public static function xls($id)
{
$xls = new PHPExcel();
//Code ...
$objWriter = new \PHPExcel_Writer_Excel5($xls);
ob_start();
$objWriter->save('php://output');
$excelOutput = ob_get_clean();
return $excelOutput;
}
In controller:
public function xls($id)
{
header('Expires: Mon, 1 Apr 1974 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D,d M YH:i:s') . ' GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
header('Content-type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename=' . $id . '.xls');
return exit(Controller::xls($id)); // <--
}