簡體   English   中英

我可以在HTML網站上創建僅包含“保存”按鈕而不包含“打開”按鈕的文件下載嗎?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM