控制器如下。如何在文件夹中生成验证码图像。任何人都可以帮忙吗?这里给出了图像文件夹路径。但图像是如何自动生成的?
function getCaptchImage(){
$response['captcha'] = $this->generateCaptcha();
echo json_encode($response);
exit;
}
function generateCaptcha() {
//Load Captcha helper
$this->load->helper('captcha');
$vals = array(
'word' => 'Security Key words',
'img_path' => './uploads/captcha/',
'img_url' => base_url() . 'captcha/',
'img_width' => 200,
'img_height' => 50,
'expiration' => 7200,
);
/* Generate the captcha */
$captcha = create_captcha($vals);
/* Store the captcha value (or 'word') in a session to retrieve later */
$this->session->set_userdata('captchaWord', $captcha['word']);
$this->session->set_userdata('captchaImage', $captcha['image']);
return $captcha['image'];
}
答案 0 :(得分:1)
您好,您可以在以下网址找到有关Captcha助手的所有信息https://ellislab.com/codeigniter/user-guide/helpers/captcha_helper.html