我正在尝试从绝对路径下载文件,但无法正常工作。我究竟做错了什么?
$fileurl = '/home/mydomain/public_html/wp-content/uploads/312tekstsecure3.pdf';
header("Content-type:application/pdf");
header('Content-Disposition: attachment; filename=' . $fileurl);
readfile( $fileurl );
最佳答案
您只需要更改一行。
<?php
$fileurl = 'yourpath/file.pdf';
header("Content-type:application/pdf");
header('Content-Disposition: attachment; filename=' . $fileurl);
readfile( $fileurl );
?>
关于php - 从绝对路径下载文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38743975/