首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >file_get_contents()错误

file_get_contents()错误
EN

Stack Overflow用户
提问于 2011-07-02 01:40:21
回答 2查看 29.5K关注 0票数 9

我在我的PHP上使用file_get_contents,它抛出了一些错误:

我的代码

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

错误:

代码语言:javascript
复制
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服务器上时,它就停止工作了。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-07-02 01:45:16

您的服务器必须将allow_url_fopen属性设置为true。在一个免费的网络主机上解释了这一点,因为它通常被禁用以防止滥用。如果你为你的主机付费,请联系你的主机,这样他们就可以为你启用它。

如果不能更改该设置,那么可以查看cURL库。

票数 15
EN

Stack Overflow用户

发布于 2011-07-02 01:56:49

您的服务器上的"allow_url_fopen“设置似乎为假,因此不允许在file_get_contents()中使用URL。

尝试使用CURL,这是一种更好、更有效的与其他服务器通信的方式。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6551379

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档