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

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

    We have just had the same issue and after adding many headers and getting a working link I then removed them one by one and found the key one for us was "Cache-Control: public" so in the end we just had

    header("Cache-Control: public"); 
    header("Content-Type: application/octet-stream");
    header("Content-Disposition: attachment; filename=some_filename.csv");
    

    which worked fine.

提交回复
热议问题