我在我的PHP上使用file_get_contents,它抛出了一些错误:
我的代码
#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服务器上时,它就停止工作了。
发布于 2011-07-02 01:45:16
您的服务器必须将allow_url_fopen属性设置为true。在一个免费的网络主机上解释了这一点,因为它通常被禁用以防止滥用。如果你为你的主机付费,请联系你的主机,这样他们就可以为你启用它。
如果不能更改该设置,那么可以查看cURL库。
发布于 2011-07-02 01:56:49
您的服务器上的"allow_url_fopen“设置似乎为假,因此不允许在file_get_contents()中使用URL。
尝试使用CURL,这是一种更好、更有效的与其他服务器通信的方式。
https://stackoverflow.com/questions/6551379
复制相似问题