Could not get Captcha image in CodeIgniter Could not get Captcha image in CodeIgniter codeigniter codeigniter

Could not get Captcha image in CodeIgniter


According to CodeIgniter API for the create_captcha function those are the possible reasons for getting a Boolean false.

 61:         if ($img_path == '' OR $img_url == '') 62:         { 63:             return FALSE; 64:         } 65:  66:         if ( ! @is_dir($img_path)) 67:         { 68:             return FALSE; 69:         } 70:  71:         if ( ! is_writable($img_path)) 72:         { 73:             return FALSE; 74:         } 75:  76:         if ( ! extension_loaded('gd')) 77:         { 78:             return FALSE; 79:         }

So make sure that:

  1. You send the img_path and img_url parameters (Notice my commentregarding a possible typo in the parameter's name).

  2. The img_path is an existing directory which is also writable

  3. You have the GD extension installed.

Path/URL

I believe it's because you're using base_url() . 'captcha' as your img_path.base_url() returns a url in the format of: http://www.domain.com/ while path should be in another format (relative), something like: ./directory/captache/.