简体   繁体   English

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

[英]file_get_contents() connection refused to local file url

For some reason file_get_contents isn't allowing me to get files which are on the same server. 由于某些原因,file_get_contents不允许我获取位于同一服务器上的文件。

This is the error I'm getting: 这是我得到的错误:

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

I know I can use the system path to get files but in this case I need to be able to test this with the URL. 我知道我可以使用系统路径来获取文件,但是在这种情况下,我需要能够使用URL进行测试。

Even if the file you are opening is on your server if you are using the url rather than the directory mechanism, you will need to set 即使您要打开的文件位于服务器上(如果您使用的是url而不是目录机制),也需要设置

allow_url_fopen = On

In you php.ini file. 在您的php.ini文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM