php 警告:file_get_contents():https:// 包装器在服务器配置中被所有人禁用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36952204/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:59:35  来源:igfitidea点击:

Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by all

php

提问by Saravana

When I am upload a csv file with zipcode it will convert and save a latitude and logitude. The error occurring a convert a zipcode to lat,lng. In my localhost its working fine. When I am uploading in a live server. I am getting this error Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /hermes/bosnaweb05a/b1410/ipg.rwdinfotechcom/vw/zipmapping/index.php on line 29. I have checked my google api key also. I can't able add php.ini file. If I upload php.ini file its shows internal server error.

当我上传带有邮政编码的 csv 文件时,它将转换并保存纬度和经度。将邮政编码转换为 lat,lng 时发生错误。在我的本地主机中它工作正常。当我在实时服务器中上传时。我收到此错误警告:file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /hermes/bosnaweb05a/b1410/ipg.rwdinfotechcom/vw/zipmapping/index.php on line 29。我也检查了我的 google api 密钥。我无法添加 php.ini 文件。如果我上传 php.ini 文件,它会显示内部服务器错误。

Here my code
function getLnt($zip){
$url = "https://maps.googleapis.com/maps/api/geocode/json?key=AIzaSyDEGgYDar8y3Bx-1FpY3hq6ON4LufoRK60&address=
".urlencode($zip)."&sensor=false";

$result_string = file_get_contents($url);
$result = json_decode($result_string, true);

$result1[]=$result['results'][0];
$result2[]=$result1[0]['geometry'];
$result3[]=$result2[0]['location'];
return $result3[0];
}

回答by Saravana

First, check your PHP file with this code and then enable the fopen in your php.ini file

首先,使用此代码检查您的 PHP 文件,然后在您的 php.ini 文件中启用 fopen

<?php 
if( ini_get('allow_url_fopen') ) {
    die('allow_url_fopen is enabled. file_get_contents should work well');
} else {
    die('allow_url_fopen is disabled. file_get_contents would not work');
}

?>

Edit the php.ini file and enable using below code

编辑 php.ini 文件并使用以下代码启用

allow_url_fopen = 1 //0 for Off and 1 for On Flag
allow_url_include = 1 //0 for Off and 1 for On Flag

回答by Prem Acharya

  1. Login to your Cpanel
  2. Under Software click on MultiPHP INI Editordemo
  3. Click on Editor Modeand select Domain demo
  4. Paste allow_url_fopen = 1and save
  1. 登录到您的 Cpanel
  2. 在软件下单击MultiPHP INI 编辑器演示
  3. 单击编辑器模式并选择域 演示
  4. 粘贴allow_url_fopen = 1并保存

回答by Pavel Rakowski

I had the same issue and I google this topic.
I could not update it from joomla direct 3.9.1 to 3.9.2 not even by uploading manually.
The reason was that before this update it forced me to upgrade php version to 7.2 so I did it from cpanel, now to solve next update will be this:

我有同样的问题,我谷歌这个话题。
即使手动上传,我也无法将它从 joomla direct 3.9.1 更新到 3.9.2。
原因是在这次更新之前,它迫使我将 php 版本升级到 7.2,所以我从 cpanel 完成了,现在解决下一次更新将是这样的:

  1. Login to cpanel
  2. Find " MultiPHP INI Editor" under software
  3. Choose your domain and select edit
  4. Set :
    "max_execution_time " to 90 (it was in mine 30)
    "memory_limit" to 256M (it was by new php enabling 32M only !)
    "post_max_size" to 100M
    "upload_max_filesize" to 100M
  1. 登录到面板
  2. 在软件下找到“MultiPHP INI Editor”
  3. 选择您的域并选择编辑
  4. 设置:
    “max_execution_time”到 90(它在我的 30 中)
    “memory_limit”到 256M(它是由新的 php 只启用 32M !)
    “post_max_size”到 100M
    “upload_max_filesize”到 100M

...because every php new version is set to default.

...因为每个 php 新版本都设置为默认值。

Enjoy ;)

享受 ;)

回答by Poiz

Try adding the Code below to your PHP File:

尝试将以下代码添加到您的 PHP 文件中:

<?php
    ini_set("allow_url_fopen", 1);

The Problem could probably be that on the Server, the PHP Setting for allow_url_fopen may have been configured differently: 0 for example. You could also do the same in your php.ini File if you have access to it.

问题可能是在服务器上,allow_url_fopen 的 PHP 设置可能配置不同:例如 0。如果您有权访问它,您也可以在 php.ini 文件中执行相同的操作。

Hope this helps....

希望这可以帮助....