0
控制器在下面给出。如何在文件夹中生成验证码图片。有人可以提供帮助吗?这里给出了图像文件夹的路径。但如何自动生成图像?如何生成验证码图片?
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'];
}