dongtong1226 2016-08-03 12:40
浏览 262
已采纳

从绝对路径下载文件

I am trying to download a file from an absolute path, but I can't get it to work. What am I doing wrong?

$fileurl = '/home/mydomain/public_html/wp-content/uploads/312tekstsecure3.pdf';
header("Content-type:application/pdf");
header('Content-Disposition: attachment; filename=' . $fileurl);
readfile( $fileurl );
  • 写回答

3条回答 默认 最新

  • douguaidian8021 2016-08-03 12:50
    关注

    You need to change just one line.

    <?php 
    $fileurl = 'yourpath/file.pdf';
    header("Content-type:application/pdf");
    header('Content-Disposition: attachment; filename=' . $fileurl);
    readfile( $fileurl );
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?