file_get_contents()错误 [英] file_get_contents() error

查看:118
本文介绍了file_get_contents()错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在PHP上使用file_get_contents,它引发了一些错误:

I am using file_get_contents on my PHP and it throws some errors:

我的代码

#try to fetch from remote
$this->remotePath = "http://some-hostname.com/blah/blah.xml
$fileIn = @file_get_contents($this->remotePath);

错误:

Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /virtual/path/to/file/outputFile.php on line 127

Warning: file_get_contents(https://some-host-name/data/inputFile.xml) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /virtual/path/to/file/outputFile.php on line 127

有什么主意吗?在我的计算机上它可以正常工作,但是当我将其移植到Web服务器时就停止了工作.

Any idea? It worked fine in my computer but stopped working when I ported it to the web server.

推荐答案

您的服务器必须具有

Your server must have the allow_url_fopen property set to true. Being on a free webhost explains it, as it's usually disabled to prevent abuse. If you paid for your hosting, get in contact with your host so they can enable it for you.

如果不能更改该设置,请查看 cURL 库.

If changing that setting is not an option, then have a look at the cURL library.

这篇关于file_get_contents()错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆