Safari adding .html to download

前端 未结 6 1649
南旧
南旧 2021-02-19 07:17

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

6条回答
  •  轮回少年
    2021-02-19 07:57

    I had the same problem

    Resolved with exit; at the end of the script

    $filename = 'report.xls';
    header('Content-Description: File Transfer');
    header('Content-Type: application/vnd.ms-excel');
    header('Content-Disposition: attachment; filename="'.$filename.'"'); 
    header('Content-Transfer-Encoding: binary');
    header('Connection: Keep-Alive');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    
    $objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
    $objWriter->save('php://output');
    exit;
    

提交回复
热议问题