douju5062 2015-01-12 10:22
浏览 60

无法使用readfile下载文件

I try to offer a pdf-file-download, handeled in dwhandler.php. All this is supposed to do is open the pdf-file or start a download of it. I tried:

<?php
header("Content-Description: File Transfer");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename='Paper.pdf'");
header("Cache-Control: must-revalidate");
readfile("Paper.pdf");
exit;
?>    

I also tried some other headers, but none worked.

The browser keeps opening the file directly in some weird coding. Here is a pic of the first few lines: http://www.directupload.net/file/d/3865/h8waniq9_jpg.htm

Has anybody an idea why this is happening? I have no idea what is left to try...

Thank you very much!

  • 写回答

2条回答 默认 最新

  • douyouqian8550 2015-01-12 10:27
    关注

    is html not a option? I know you can offer files to download with simply using html 5 by doing

    <a href="example.pdf" download>download not open it</a>
    

    Take a look into: Forcing to download a file using PHP

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作