繁体   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