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

后端 未结 12 512
梦如初夏
梦如初夏 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:52

    Don't we love IE? :)

    Try using those headers:

      header("Pragma: public");
      header("Expires: 0");
      header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
      header("Cache-Control: private",false);
      header("Content-Type: application/octet-stream");
      header("Content-Disposition: attachment; filename=\"exportevent.csv\";" );
      header("Content-Transfer-Encoding: binary"); 
    

    I think that the octet-stream content type forces IE to download the file.

提交回复
热议问题