如何在 codeigniter 2.1.0 加载帮助程序 codeigniter 中创建验证码?当我有模型 m_captcha 时:
function __construct()
{
parent::__construct();
}
function setCaptcha()
{
$this->load->helper('captcha');
$vals = array(
'img_path' => './asset/captcha',
'img_url' => base_url().'/asset/captcha',
'expiration' => 3600,// one hour
'font_path' => './system/fonts/georgia.ttf',
'img_width' => '140',
'img_height' => 30,
'word' => random_string('numeric', 6),
);
$cap = create_captcha($vals);
if ($cap)
{
$capdb = array(
'captcha_id' => '',
'captcha_time' => $cap['time'],
'ip_address' => $this->CI->input->ip_address(),
'word' => $cap['word']
);
$query = $this->db->insert_string('captcha', $capdb);
$this->db->query($query);
}else {
return "Captcha not work" ;
}
return $cap['image'] ;
}
我有控制器 c_login :
function __construct()
{
parent::__construct();
$this->load->model('m_captcha');
}
public function index()
{
$this->load->helper('captcha');
$data = $this->m_captcha->setCaptcha();
$this->load->view('login/v_form',$data);
}
我有看法:
<?php echo form_open('c_login'); ?>
<?php echo $cap['image']; ?>
<?php echo form_error('captcha');?>
<?php echo form_close(); ?>
为什么验证码无法显示?在 sms/asset/captcha 中定位文件夹和图像验证码。sms 是文件夹根 Codeigniter。