我使用readfile来读取文件,但它不适用于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 基本路径将在读取文件中工作,否则您将不得不使用 fopen。
谢谢阿米特