【问题标题】:The file GeoLite2-Country.mmdb does not exist or is not readableGeoLite2-Country.mmdb 文件不存在或不可读
【发布时间】:2018-06-27 23:47:11
【问题描述】:

我在一个小项目中,我需要收集向一个网站提交联系表格的人的国家表格,现在我正在使用 MaxMind/GeoLite2 读取带有 的数据库文件GeoIp2 v2.0(从作曲家安装),我收到下一条错误消息。

文件 GeoLite2-Country.mmdb 不存在或不可读。

我正在使用 CodeIgniter v3.1.6

这是完整的错误信息:

An uncaught Exception was encountered
Type: InvalidArgumentException

Message: The file "http://localhost/isite/assets/geoip2db/GeoLite2-Country.mmdb" does not exist or is not readable.

Filename: C:\xampp\htdocs\isite\vendor\maxmind-db\reader\src\MaxMind\Db\Reader.php

Line Number: 48

Backtrace:

File: C:\xampp\htdocs\isite\vendor\geoip2\geoip2\src\Database\Reader.php
Line: 53
Function: __construct

File: C:\xampp\htdocs\isite\application\controllers\Main.php
Line: 28
Function: __construct

File: C:\xampp\htdocs\isite\index.php
Line: 317
Function: require_once

GeoLite2-Country.mmdb 文件在那里。

这是我调用 GeoIp2 类的函数:

public function contact_submit(){
$reader = new GeoIp2\Database\Reader(base_url().'assets/geoip2db/GeoLite2-Country.mmdb');
$record = $reader->country($_SERVER['REMOTE_ADDR']);
$data = array(
    'name' => $this->input->post('name'),
    'mail' => $this->input->post('mail'),
    'phone' => $this->input->post('phone'),
    'comment' => $this->input->post('comment'),
    'USER_AGENT' => $_SERVER['HTTP_USER_AGENT'],
    'ADDR' => $_SERVER['REMOTE_ADDR'],
    'PORT' => $_SERVER['REMOTE_PORT'],
    'ISO' => $record->country->isoCode,
    'COUNTRY_NAME' => $record->country->name,
    'COUNTRY_STATE' => $record->mostSpecificSubdivision->name,
    'COUNTRY_STATE_ISO' => $record->mostSpecificSubdivision->isoCode,
    'CITY_NAME' => $record->city->
    'POSTAL_CODE' => $record->postal->code,
    'LONGITUDE' => $record->location->longitude,
    'LATITUDE' => $record->location->latitude
);
if($this->MainModel->submitComment($data))
    redirect(base_url().'index.php/main/contact?statusMessage=1', 'location');
else
    redirect(base_url().'index.php/main/contact?statusMessage=0', 'location');
}

如果需要更多信息,请发表评论,我会尽快添加它

【问题讨论】:

    标签: maxmind geoip2 geolite2


    【解决方案1】:

    构造函数获取本地数据库文件的路径,但您似乎为它提供了 HTTP URI。您需要删除或替换base_url()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-05
      • 1970-01-01
      • 2020-02-26
      • 2014-05-19
      • 2017-08-05
      • 1970-01-01
      • 1970-01-01
      • 2014-09-04
      相关资源
      最近更新 更多