Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php readfile不'';URL路径无效_Php_Readfile - Fatal编程技术网

Php readfile不'';URL路径无效

Php readfile不'';URL路径无效,php,readfile,Php,Readfile,我使用readfile来读取文件,但它不适用于URL路径。所以,我给出了它的物理路径。如何使用URL路径 header('Content-Type: application/octet-stream'); header("Content-Transfer-Encoding: Binary"); header("Content-disposition: attachment; filename=\"" . basename($path) . "\""); readfile($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

谢谢
Amit

因此,如果“允许url\u fopen”选项未启用,则您需要将readfile函数更改为fopen。谢谢。这也是一个权限问题吗?这也可能是权限问题,但首先我们应该检查的是allow_url_fopen=On,如果是一个,然后检查权限,如果更新代码以使用fopen而不是readfile仍然不起作用。这个问题的答案对您有效吗?