我正在使用wordpress。我制作了一个上传pdf文件的meta字段,并成功上传了pdf文件。现在,我叫meta值在HREF链接,下载PDF file.But的问题是,它可以打开该文件,但不download.For这个我搜索代码,从href链接下载pdf文件
<?php
header("Content-Disposition: attachment; filename=$event_flyer");
?>
$ event_flyer用于访问元值。
但它没有为特定的href工作,它只是在整个页面上刷新。其实
header("Content-disposition: attachment; filename=$pathtopdf"); header("Content-type: application/octet-stream"); readfile($pathtopdf);
感谢它的工作 –
请记住,下载属性的浏览器兼容性还不是很好:[caniuse.com/#feat=download] (http://caniuse.com/#feat=download) – Theunis