file_get_contents()连接拒绝本地文件url

时间:2014-11-06 13:38:25

标签: php apache file-get-contents

由于某种原因,file_get_contents不允许我获取位于同一服务器上的文件。

这是我得到的错误:

file_get_contents(http://www.my-url.com/image.jpg): failed to open stream: Connection refused

我知道我可以使用系统路径来获取文件,但在这种情况下,我需要能够使用URL对其进行测试。

1 个答案:

答案 0 :(得分:1)

如果您使用的是url而不是目录机制,即使您打开的文件在服务器上,也需要设置

allow_url_fopen = On

在你的php.ini文件中。