在手册上说直接在配置文件里添加

'captcha'  => [        // 验证码字符集合3.        
    'codeSet'  => '2345678abcdefhijkmnpqrstuvwxyzABCDEFGHJKLMNPQRTUVWXY',         // 验证码字体大小(px)5.   
    'fontSize' => 28,         // 是否画混淆曲线7.      
    'useCurve' => false,          // 验证码图片高度9.      
    'imageH'   => 50,        // 验证码图片宽度11.       
    'imageW'   => 200,         // 验证码位数13.       
    'length'   => 4,         // 验证成功后是否重置        15.      
    'reset'    => true
    ],

但是tp5.0的需要自己添加验证码类,而在tp5.0.5的版本中则自带有此类只要有这个(现在已更新到5.0.9)

tp5.0验证码

 

我们只需在方法中添加

 $capthcha=new Captcha();
        if (!$capthcha->check($txt_yzm)){
            $this->error('验证码不正确');
        }

html:

 <div class="yzm"> 
                    <img  src="{:captcha_src()}" class="verify" onclick="resVerify()" alt="验证码" />
                 <a href="javascript:resVerify();"  >看不清,换一张</a>
                 </div>

 或者

<img src="{:captcha_src()}" class="verify" onclick="javascript:this.src='{:captcha_src()}?rand='+Math.random()" >

 如果这样也不行的话可以去我的git下载源码  https://github.com/liqin12/tp5.0.9.git,里面还有文件上传O(∩_∩)O~,希望能对大家有帮助

相关文章:

  • 2021-06-07
  • 2022-01-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-16
  • 2021-12-22
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-04-09
  • 2021-07-28
  • 2022-01-01
  • 2021-04-29
  • 2021-04-05
  • 2021-08-13
相关资源
相似解决方案