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

浏览:12319 发布日期:2016/10/08 分类:ThinkPHP5专区
首先使用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();" />';
}
最佳答案
评论( 相关
后面还有条评论,点击查看>>