phpcodeigniter-3captcha

Codeigniter 3 captcha helper create_captcha returns bool


Hi I am trying to captcha validation but when I call create_captcha function it returns bool/false instead of array. I can't figure out whats the issue ? .I am using linux/php-7.3 and also tried enabling the gd library but no luck.

$this->load->helper('captcha');
$vals = array(
  'img_url' => base_url('public/captcha'),
  'img_path' => FCPATH.'public/captcha',
  'img_height' => 45,
  'word_length' => 5,
  'img_width' => '45',
  'font_size' => 10
);
var_dump($vals);
$cap = create_captcha($vals);
echo $cap['image'];

Solution

  • The Captcha word is missing in your snippets

    $vals = array(
        'word' => 'Captcha word',
        'img_path' => './captcha/',
        'img_url' => 'http://example.com/captcha/',
        'font_path' => './path/to/fonts/texb.ttf',
        'img_width' => '150',
        'img_height' => 30,
        'expiration' => 7200
        );
    
    $cap = create_captcha($vals);
    echo $cap['image'];
    

    Note The "captcha" folder must be writable (666, or 777)