codeigniter 验证码帮助程序代码触发器错误- imagettftext():无法找到/打开字体

kpbpu008  于 2022-12-06  发布在  其他
关注(0)|答案(2)|浏览(80)

请帮助我解决这个问题。我想使用验证码在我的登录页面使用验证码助手在CodeIgniter,但得到一些错误,像这样:
遇到PHP错误
严重性:警告
消息:imagettftext():无法找到/打开字体
文件名:文件名:

这是我的控制器:

public function login() {

    $data['captcha'] = $this->set_captcha();
    $this->load->view('access/login', $data);

}

public function set_captcha() {

    $vals = array(
        'img_path'      => './assets/img/captcha/',
        'img_url'       => base_url('assets/img/captcha'),
        'font_path'     => './assets/fonts/Kalam-Regular.ttf',
        'img_width'     => 175,
        'img_height'    => 55,
        'expiration'    => 3600,
        'word_length'   => 5,
        'font_size'     => 17,
        'pool'          => '0123456789abcdefghijklmnopqrstuvwxyz',

        // White background and border, black text and red grid
        'colors'        => array(
            'background' => array(255, 255, 255),
            'border' => array(255, 255, 255),
            'text' => array(160, 160, 160),
            'grid' => array(255, 183, 206)
        )
    );

    $cap = create_captcha($vals);

    return $cap['image'];

}

然后在视图中回显captcha变量。
这个问题只显示在windows(XAMPP)中,而不是在我的ubuntu服务器中。请告诉我,如果有任何重复的这篇文章,我已经搜索了帖子和谷歌的列表,但没有发现同样的问题。

5sxhfpxr

5sxhfpxr1#

当我开始使用xampp进行测试时,我就遇到了这种情况,所以我所做的是......我确实更改为'font_path' => base_url('system/fonts/texb.ttf'),

f3temu5u

f3temu5u2#

尝试检查php.ini配置
打开并搜索extension=fileinfoextension=gd添加到extension=fileinfo后面的下一行中,然后保存并关闭文件。
注意:如果存在extention=gd2,请将分号放在;extention=gd2前面

相关问题