[英]Can I create a file download on my html site that only includes the “save” button, not the open button?
我的代碼如下。 這可行,但是我想知道是否有一種方法可以排除“打開”按鈕並強迫用戶保存文件。 謝謝!
<?php
header("Content-disposition: attachment; filename=myfile.pdf");
header("Content-type: application/pdf");
readfile("myfile.pdf");
?>
嘗試這個
<?php
header("Content-disposition: attachment; filename=myfile.pdf");
header("Content-type: application/pdf");
header('Content-Description: File Transfer');
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
readfile("myfile.pdf");
?>
將此代碼放在另一個文件中,例如file.php,然后使用定位標記調用它
<a href='file.php'>Download PDF</a>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.