In php Instead of downloading csv file it gets open in the browser

后端 未结 4 636
梦毁少年i
梦毁少年i 2021-01-16 09:33

I\'m trying to download a CSV file through the browser. The script is partially working, because so far I managed to display the CSV on screen, but the download is not start

4条回答
  •  余生分开走
    2021-01-16 09:57

    You might try this.

    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=\"$filename.csv\";" );
    
    print $content;
    

提交回复
热议问题