【发布时间】: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 服务器中显示。 请告诉我这篇文章是否有任何重复,我已经搜索了帖子列表和谷歌,但没有发现同样的问题。
【问题讨论】:
-
试试这个 [youtu.be/TU_8b9SRe_k]
-
我已经在你的链接中做了同样的事情
-
看看这是否有帮助:stackoverflow.com/a/10366726/938436
-
@Andy ,尝试在 img_path 和 font_path 中给出相对路径并再次测试
标签: php codeigniter captcha