TP5 在云服务器下 验证码不显示的解决方案

tp5使用 think-captcha 后,本地环境正常的显示,可放到云服务器上却显示不了。

 

方法其实很简单,在 vendor/topthink/think-captcha/src/CaptchaController.php中加上这个ob_clean();这样就能够清除缓存区

namespace think\captcha;

use think\Config;

class CaptchaController
{
    public function index($id = "")
    {
        $captcha = new Captcha((array)Config::get('captcha'));
       ob_clean();
        return $captcha->entry($id);
    }
}

用此即可解决验证码不出来的问题。

posted @ 2019-08-08 21:51  带着蚂蚁去散步  阅读(566)  评论(0编辑  收藏  举报