当我上传带有邮政编码的 csv 文件时,它将转换并保存纬度和经度。将邮政编码转换为经纬度时发生错误。在我的本地主机中它工作正常。当我在实时服务器中上传时。我收到这个错误警告:file_get_contents():https:// 包装器在服务器配置中被禁用,方法是第 29 行 /hermes/bosnaweb05a/b1410/ipg.rwdinfotechcom/vw/zipmapping/index.php 中的allow_url_fopen=0。我也检查了我的 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];
}
首先,使用此代码检查您的 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');
}
?>
编辑 php.ini 文件并启用使用以下代码
allow_url_fopen = 1 //0 for Off and 1 for On Flag
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)