|
首先是个控制器中的captcha方法
public function captcha()
{
$this->load->helper('url');
$this->load->helper('captcha');
//设置验证码参数
$vals = array(
'img_path' => './data/captcha/', //验证码图片保存路径
'img_url' => 'http://localhost/yuekeueditor/data/captcha/', //验证码显示路径
'img_width' => '120', //验证码图片宽度
'expiration' => 120 //验证码保存时长,超时自动销毁
);
$cap = create_captcha($vals);
header('Content-Type: image/jpeg');
echo $cap['image'];
}
这样验证码是生成了。但是在某个页面中这么调用 <img id="codeimage" src="<?php echo site_url('test/captcha');?>" /> 这样根本无法显示 在html中他是这样的 <img id="codeimage" onclick="javascript:this.src='http://localhost/yuekeueditor/index.php/test/captcha?'+Math.random();" src="http://localhost/yuekeueditor/index.php/test/captcha" /> 知道的能否回答一下
|
|