【问题标题】:cant create captcha using codeigniter captcha helper无法使用 codeigniter 验证码助手创建验证码
【发布时间】:2021-09-19 04:42:33
【问题描述】:

我正在使用验证码,我想使用 cpatcha 助手创建验证码!我阅读了用户指南并编写了一段代码,但它无法创建验证码,所以我使用 var_dump 并返回 bool(false),我的代码如下:

<?php
class test_captcha extends CI_Controller{
    public function main(){
        $this->load->helper('captcha');
        $this->load->helper('url');       
        $random=rand(1000, 2000);
        $vals=array(
            'word' => $random,
            'img_path' => './files/',
            'img_url' => base_url().'files/',
            'img_width' => 600,
            'img_height' => 400,
            'expiration' => 100,
            'word_length' => 4,
            'pool' => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
            'img_id' => 'imgcaptcha',
            'font_size' => 18
        );
        $cap=create_captcha($vals);
        echo $cap['image'];
    }
}

结果是 bool(false),所以我尝试这些代码来检查:

        if(is_dir($vals['img_path']) && is_readable($vals['img_path']) && is_writable($vals['img_path']) && extension_loaded('gd')){
            echo 'passed';
        }

返回“通过”。

谁能帮我解决这个问题?

【问题讨论】:

  • 你检查是否安装了GD镜像库?
  • 是的,我已经检查过了,已经安装并加载了

标签: php codeigniter xampp captcha


【解决方案1】:

检查您的验证码文件夹的文件夹权限。我 chmod 667 加载了文件夹和验证码对象,并且能够回显“图像”字符串。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-21
    • 1970-01-01
    相关资源
    最近更新 更多