How do I force files to open in the browser instead of downloading (PDF)?

后端 未结 13 1274
别跟我提以往
别跟我提以往 2020-11-22 04:15

Is there a way to force PDF files to open in the browser when the option \"Display PDF in browser\" is unchecked?

I tried using the embed tag and an iframe, but it o

13条回答
  •  耶瑟儿~
    2020-11-22 05:12

    Open downloads.php from rootfile.

    Then go to line 186 and change it to the following:

            if(preg_match("/\.jpg|\.gif|\.png|\.jpeg/i", $name)){
                $mime = getimagesize($download_location);
                if(!empty($mime)) {
                    header("Content-Type: {$mime['mime']}");
                }
            }
            elseif(preg_match("/\.pdf/i", $name)){
                header("Content-Type: application/force-download");
                header("Content-type: application/pdf");
                header("Content-Disposition: inline; filename=\"".$name."\";");
            }
    
            else{
                header("Content-Type: application/force-download");
                header("Content-type: application/octet-stream");
                header("Content-Disposition: attachment; filename=\"".$name."\";");
            }
    

提交回复
热议问题