验证码 laravel

1.下载laravel扩展包

    https://packagist.org
    gregwar/captcha
    composer require gregwar/captcha

2.验证生成

    public function captcha($tmp){
        $builder = new CaptchaBuilder;
        $builder->build();
        Session::put('imgcode',strtoupper($builder->getPhrase()));
        header('Content-type: image/jpeg');
        $builder->output();
    }

3.路由指引

    Route::get('captcha/{tmp}', 'spicyController@captcha');

4.前端显示

<div class="col-md-4">
     <input id="imgcode" type="text" class="form-control" placeholder="验证码" name="imgcode">
      @if($errors->has('imgcode'))
        <p style="color:red">{{$errors->first('imgcode')}}</p>
      @endif
     </div>
     <button  class="btn btn-default" style=" padding: 0px 0px;">
     <img src="{{url('/captcha/1')}}" alt="" onclick="this.src='{{url('/captcha')}}/'+Math.random()" width="80" height="34" border="0">
     </button>
</div>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Spicy姜

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值