<a href="javascript:void(0);" onclick="load_captcha(‘captcha‘,‘<?php echo site_url(‘index/show_captcha‘)?>‘);" title="看不清,换一张" id="captcha" ><?php echo $image;?></a> function load_captcha(id,url) { $("#"+id).html(‘‘); $("#"+id).load(url); }
Controller中方法
public function captcha() { $this->load->helper(‘captcha‘); $vals = array( ‘word‘ => rand(1000,9999), ‘img_path‘ => ‘./captcha/‘, ‘img_url‘ => base_url().‘captcha/‘, ‘font_path‘ => ‘./system/fonts/texb.ttf‘, ‘img_width‘ => ‘90‘, ‘img_height‘ => 35, ‘expiration‘ => 7200 ); $this->session->set_userdata(array(‘word‘=>$vals[‘word‘])); $cap = create_captcha($vals); return $cap[‘image‘]; } public function show_captcha() { echo $this->captcha(); }
时间: 2024-10-10 04:39:28