yii的项目开发过程中,经常使用到验证码,yii框架提供了CCaptchaAction类,来提供验证码图片功能,经常会碰到验证码图片不显示的问题。 主要有两个问题导致: 1、bom问题(把文件涉及到bom的php代码去掉bom即可) 2、 输出图像之前,没有加ob_clean()清空输出缓冲区: //加此代码块解决 if(function_exists('ob_clean')){ @ob_clean(); } imagecolordeallocate($image,$foreColor); header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Transfer-Encoding: binary'); header("Content-type: image/png"); imagepng($image); imagedestroy($image);
Yii CCaptchaAction验证码图片不显示问题汇总
猜你喜欢
转载自lunzi.iteye.com/blog/2281064
今日推荐
周排行