美文网首页
THINKPHP5不能正确显示验证码的问题解决

THINKPHP5不能正确显示验证码的问题解决

作者: 夏日De雨 | 来源:发表于2019-01-16 13:22 被阅读0次

首先使用Composer安装think-captcha扩展包:

composer require topthink/think-captcha

在安装扩展的目录下有think-captcha文件夹

对于不能显示验证码的问题

在 think-captcha/src/helper.php  第39行

添加$root= \think\Url::root('/index.php');

使得固定根路径,这样就可以正确显示验证码了

修改 captcha_img 函数以期达到模板中只要添加{:captcha_img()}就可以点击更换验证码function captcha_img($id = "")

{

    return '<img src="' . captcha_src($id) . '"  alt="点击更换"  onclick="this.src=\''.captcha_src().'?id=\'+Math.random();" />';

}

//产生的原因,项目为INDEX而且主页为INDEX.PHP缺省状态.补全路由可正常显示.

相关文章

网友评论

      本文标题:THINKPHP5不能正确显示验证码的问题解决

      本文链接:https://www.haomeiwen.com/subject/roqmdqtx.html