|
试了下自带的验证码的库,发现直接使用控制器的地址可以正常显示,但是在视图中src地址调用控制器地址的时候就显示红叉了,如下错误
Resource interpreted as Image but transferred with MIME type text/html
是说MIME类型不是图片类型,在方法里加header也不行,求教各位!!!
如下是控制器的方法:
PHP复制代码
public function auth ()
{
//header("Content-Type:image/jpeg");
$this->load->helper('captcha');
$captcha_conf = array(
'img_path' => './captcha/',
'img_url' => base_url () . 'captcha/',
'font_path' => '',
'img_width' => 100,
'img_height' => 30,
'expiration' => 60
);
$image = create_captcha ($captcha_conf);
echo isset($image['image']) ? $image['image'] : '';
}
复制代码
如下是视图:
HTML复制代码
<img src="<?php echo site_url('home/auth'); ?>" alt="" onclick="this.src=this.src + Math.random()" />
复制代码
先谢谢各位了!!
|
|