【问题标题】:Captcha Helper Codeigniter Error - imagettftext(): Could not find/open fontCaptcha Helper Codeigniter 错误 - imagettftext(): 找不到/打开字体
【发布时间】:2022-05-03 06:20:46
【问题描述】:

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

遇到了 PHP 错误

严重性:警告

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

文件名:helpers/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 服务器中显示。 请告诉我这篇文章是否有任何重复,我已经搜索了帖子列表和谷歌,但没有发现同样的问题。

【问题讨论】:

标签: php codeigniter captcha


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-30
    • 2015-07-19
    • 2023-03-07
    • 2012-05-09
    • 2018-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多