验证码帮助程序代码点火器错误 - imagettftext():找不到/打开字体



请帮我解决这个问题。我想在 CodeIgniter 中使用验证码助手在我的登录页面中使用验证码,但遇到了这样的错误:

遇到 PHP 错误

严重性:警告

消息: imagettftext((: 找不到/打开字体

文件名:帮助程序/captcha_helper.php

====

================================================

这是我的控制器:

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

然后我只是在视图中回显验证码变量。

该问题仅显示在Windows(XAMPP(中,但不显示在我的Ubuntu服务器中。请告诉我这篇文章是否有任何重复,我已经搜索了帖子列表和谷歌,但没有发现同样的问题。

当我开始使用 xampp 进行测试时,它发生在我身上,所以我所做的是......我确实改成了'font_path' => base_url('system/fonts/texb.ttf'),

尝试检查你的 php.ini配置

打开并搜索extension=fileinfoextension=fileinfo后在下一行添加extension=gd,然后保存并关闭文件。

注意:如果存在extention=gd2请将分号放在前面;extention=gd2

最新更新