php - 从绝对路径下载文件

标签 php header readfile absolute-path

我正在尝试从绝对路径下载文件,但无法正常工作。我究竟做错了什么?

$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/

相关文章:

php - 当链接可以是父链接或子链接时查询生成父名称

PHP 增量运算符

php - Laravel FirstOrCreate 和 Save() 重复条目

c++ - Visual Studio 不区分 C header 和 C++ header

C - 读取文件和段错误

C++文件读取错误

php 错误显示未定义的 mysqli_query

html - 如何为 weebly 创建新的顶部标题

Android:如何从 ExpandableListView 中删除标题 View ?

java - 读取 jar/war 文件中的 maven.properties 文件