代码上传服务器之后验证码不显示问题
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);
}
}

本文解决TP5框架使用think-captcha组件在云服务器上无法显示验证码的问题,通过在CaptchaController.php文件中添加ob_clean()函数清除缓存区,确保验证码图片能够正确加载。
802

被折叠的 条评论
为什么被折叠?



