|  | 
 
| 本帖最后由 andyzu 于 2013-6-25 11:53 编辑 
 以下代码,是我在login.php 登录页面里写的三个方法:
 
 PHP复制代码 复制代码 
function captcha() {
  $vals = array(
    'img_path' => './captcha/',
    'img_url' =>  base_url().'captcha/',
    'font_path' => './captcha/fonts/georgiai.ttf',
    'img_width' => '80',
    'img_height' => '28',
    'expiration' => 300     );
  
  $captcha =  create_captcha($vals);
  return $captcha;  
}
 
 
function  captcha_URL() {
  $data = $this->captcha();
  echo  $data['imageURL'];      
 
//这部分是我改造了captcha_helper.php文件,return array('captchaWords' => $word, 'time' => $now, 'image' => $img , 'imageURL' =>$img_url.$img_name ); 我在这个返回值里增加了 'imageURL' =>$img_url.$img_name;
 
//而img 我也改造成:$img = "<img src=\"$img_url$img_name\" width=\"$img_width\" height=\"$img_height\" style=\"border:0;\" alt=\"验证码\" id=\"captcha_images\" />";
 
//这个函数在浏览器里显示的结果为(类似) http://localhost/iHOUSER2/captcha/1372101430.3029.jpg
}
 
 
function  index(){
  
  $this->load->library('session'); //初始化session
  $captcha = $this->captcha();
  
  //把验证码的内容,保存成session
  $this->session->set_userdata(array('s_captcha' => $captcha['captchaWords']));   
  $this->load->view("qtadmin/v_login" , $captcha);
}
 我的JS代码写的是:
 
 JS复制代码 复制代码 <script type="text/javascript">
 function changeCode(){
 document.getElementById('captcha_images').src ="<?php echo base_url()?>login/captcha_URL";
 }
 </script>
 
 
 现在的问题是,首次访问,验证码图片正常访问,但是如果点击图片刷新后,就出现一个无法显示图片的红叉!
 如何解决?
 
 | 
 |