读取文件不适用于 URL 路径
readfile doesn''t work for URL path
我使用 readfile 读取文件,但它不适用于 URL 路径。所以,我给出了它的物理路径。如何使用 URL 路径 ?
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=\"" . basename($path) . "\"");
readfile($path);
如果php.ini启用了名为
的选项
allow_url_fopen=On
然后 url 基本路径将在 readfile 中工作,否则你将不得不使用 fopen。
谢谢
阿米特
我使用 readfile 读取文件,但它不适用于 URL 路径。所以,我给出了它的物理路径。如何使用 URL 路径 ?
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=\"" . basename($path) . "\"");
readfile($path);
如果php.ini启用了名为
的选项allow_url_fopen=On
然后 url 基本路径将在 readfile 中工作,否则你将不得不使用 fopen。
谢谢 阿米特