0

我的代码如下。这可行,但我想知道是否有办法排除“打开”按钮并强制用户保存文件。谢谢!

<?php
header("Content-disposition: attachment; filename=myfile.pdf");
header("Content-type: application/pdf");
readfile("myfile.pdf");
?>
4

1 回答 1

0

尝试这个

<?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>
于 2013-11-01T05:16:32.587 回答