Using php to force download a pdf

后端 未结 5 1528
渐次进展
渐次进展 2020-12-17 21:25

Im trying to get a website to have a button that forces a download of a pdf.

Heres the html of the button:

    
           


        
5条回答
  •  一个人的身影
    2020-12-17 21:46

    $file_url = www.example.com/pdffolder/$pdfname;
    header('Content-Type: application/pdf');
    header("Content-Transfer-Encoding: Binary");
    header("Content-disposition: attachment; filename=".$pdfname);
    readfile($file_url);
    

提交回复
热议问题