小编按Tp5.1的手册,在需要显示验证码的位置插入了
  1. <div><img src=”{:captcha_src()}” alt=”captcha” /></div>

复制代码

代码,浏览器运行时出现下图所示的致命错误。

Thinkphp5.1以上版本默认没安装captcha,需要通过composer安装

1、下载安装captcha,(注意TP5.1以前是1.0版本,5.1以上是2.0版本的)
   composer require topthink/think-captcha 2.*
     注意:这里执行命令时路径一定要对,会自动安装到正确的路径,就无需手动移动文件和修改文件了。

2、执行下载命令后,一般会自动下载到vendor/topthink下,如果不在该目录下,移动到这个目录下。

3、打开vendor/composer/autoload_psr4.php,检查是否配置think\captcha的路径。

 正确的是这样的:

  1. return array(
  2.     ‘think\\composer\\’ => array($vendorDir . ‘/topthink/think-installer/src’),
  3.     ‘think\\captcha\\’ => array($vendorDir . ‘/topthink/think-captcha/src’),
  4.     ‘app\\’ => array($baseDir . ‘/application’),
  5. );

复制代码

4、检查composer下autoload_files.php文件,看是否有验证码的配置。正确的是这样的:

  1. return array(
  2.     ‘1cfd2761b63b0a29ed23657ea394cb2d’ => $vendorDir . ‘/topthink/think-captcha/src/helper.php’,
  3. );

复制代码

需要将topthink/think-captcha目录及有关配置文件都提交到服务器,验证码类才能生效。

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部