Closed baidut closed 8 years ago
手动在根目录下创建captcha文件夹,目录必须可写(666, or 777) ,存放临时生成的验证码,验证码每次请求都会删除过期的图片,expiration
$this->load->helper('url');
$this->load->helper('captcha');
$vals = array(
'word' => rand(1000,9999),//'Random word',
'img_path' => './captcha/',
'img_url' => base_url('captcha/'),
'img_width' => '150',
'img_height' => 30,
'expiration' => 7200
);
$cap = create_captcha($vals);
echo $cap['image'];
session_start();
$_SESSION['cap']= $cap['word']; // 验证时看$_SESSION['cap']是否和提交的验证码一致即可
兄弟连 CodeIgniter 视频教程 18: CI中的验证码