当前位置:网站首页>Laravel8 implementation of picture verification code

Laravel8 implementation of picture verification code

2022-06-23 05:15:00 Life goes on and battles go on

1、 adopt composer Install verification code package

stay Composer To carry out the following orders

composer require mews/captcha

2、 To configure

stay config/app.php in find aliases Add the following code to the array

'Captcha' => Mews\Captcha\CaptchaServiceProvider::class,

3、 Generate configuration files

stay Composer To carry out the following orders , If the pop-up option , Select to config, my config Of tag yes 11, Input 11 Back carriage return , Then it will be in config Generate configuration files in the folder ; In the configuration file length Is the number of digits of the generated verification code ;

 php artisan vendor:publish

4、 The front end uses the verification code

Add... Where needed

<img src="{
   {captcha_src()}}" id="captcha">

Switch verification code

<script>
$('#captcha').click(function(){
    $(this).prop('src',"{
   {captcha_src()}}"+Math.random(1000,9999));
})
</script>

原网站

版权声明
本文为[Life goes on and battles go on]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206230146380842.html