How do I get csv file to download on IE? Works on firefox

后端 未结 12 523
梦如初夏
梦如初夏 2020-12-02 10:10

I\'m struggling with an odd error. I have a simple web app that grabs stuff from a DB then outputs it as a downloadable csv file. It works on firefox and chrome, but IE fail

12条回答
  •  死守一世寂寞
    2020-12-02 10:45

    We recently ran into this problem ourselves. See this MSKB article

    These are the headers we ended up having to use to get it to work over SSL.

    header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Pragma: public");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: public");
    header("Content-Type: application/octet-stream");
    header("Content-Disposition: attachment; filename=\"$file_name\";");
    header("Content-length: " . strlen($csv_string));
    

提交回复
热议问题