警告:file_get_contents():服务器配置中的所有服务器均禁用https://包装器 [英] Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by all

查看:119
本文介绍了警告:file_get_contents():服务器配置中的所有服务器均禁用https://包装器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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];
}

推荐答案

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

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

<?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');
}

?>

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

Edit the php.ini file and enable using below code

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

这篇关于警告:file_get_contents():服务器配置中的所有服务器均禁用https://包装器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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