Force Download Only Displays in Browser, Doesn't Prompt for Download

前端 未结 2 1069
孤独总比滥情好
孤独总比滥情好 2020-12-20 04:20

I can\'t seem to figure this out and I know it\'s something simple. I am building the back-end to a very basic content management system. For this specific piece, I am jus

2条回答
  •  太阳男子
    2020-12-20 04:53

    Headers I use for download:

            header("Pragma: public");
            header("Expires: 0");
            header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
            header("Cache-Control: public");
            header("Content-Description: File Transfer");
            header("Content-type: application/force-download");
            header("Content-Disposition: attachment; filename=".$file); 
            header("Content-Type: application/octet-stream");
            header("Content-Transfer-Encoding: binary");
            header("Content-Length: ".$bytes."");
    

提交回复
热议问题