Action Captcha Don't Generate Image

HI :)

In the begin of my project i made register system with captcha…

Now i want check my work and i get nice suprise…

Captcha picture doesn’t generate…

It’s my code :

SiteController




	public function actions()

	{

		return array(

			// captcha action renders the CAPTCHA image displayed on the contact page

			'captcha'=>array(

				'class'=>'CCaptchaAction',

				'backColor'=>0xFFFFFF,

				'testLimit'=>0,

			),

			// page action renders "static" pages stored under 'protected/views/site/pages'

			// They can be accessed via: index.php?r=site/page&view=FileName

			'page'=>array(

				'class'=>'CViewAction',

			),

		);

	}



Model :


array('captcha', 'captcha', 'allowEmpty'=> !CCaptcha::checkRequirements(),'on'=>'register'),

maybe is something wrong in urlmanager in config/main?


		'urlManager'=>array(

			'urlFormat'=>'path',

			'rules'=>array(		

				'<controller:\w+>/<id:\d+>'=>'<controller>/view',

				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

				'<controller:\w+>/<action:\w+>/<id:\d+>/<id2:\d+>'=>'<controller>/<action>',


				//'<controller:\w+>/<action:\w+>/<param:\w+>'=>'<controller>/<action>',

				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

				//array('news/show', 'pattern'=>'news/show/<id:\d+>', 'verb'=>'GET'),

			),

			

		),



When i go to link - http://localhost/index.php/site/captcha in normal case, it should send me picture with captcha. Now, it’s writing error that picture contained a errors

Please help :(

RESOLVE:

HAHHAHAHAHAHAHAHAHAHAHAHAHAHAHAH

I SPEND 3 hours for this problem :

my index.php :





<?php //echo dirname(__FILE__) ; ?>

<?php //echo dirname(__FILE__).'/../../yiiroot/framework/yii.php'; ?>

<?php //echo dirname(__FILE__).'/protected/config/main.php'; ?>




<?php


// change the following paths if necessary

$yii=dirname(__FILE__).'/../../yiiroot/framework/yii.php';

$config=dirname(__FILE__).'/protected/config/main.php';


//$yii=dirname(__FILE__).'/../yiiroot/framework/yii.php';

//$config=dirname(__FILE__).'/../protected/config/main.php';


// remove the following lines when in production mode

defined('YII_DEBUG') or define('YII_DEBUG',true);

// specify how many levels of call stack should be shown in each log message

defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);


require_once($yii);

Yii::createWebApplication($config)->run();

?>



I had to delete firstly 3 lines and now all go right…

But is my next question is…

WHY ??????????????

Maybe the space/linebreak resolves in some output and if headers are sent, if messes up your session. Captcha needs it I guess.

Yii Captcha is problematic ;)

does your captcha action restricted by accessRules. if yes then make sure to allow all users to access captcha action

If you are talking about the 3 echo lines, then yii is sending http text headers BEFORE the captcha command can send the http IMAGE headers. I would guess this would mess up the browser. not knowing if it’s a picture or text?

Why you had those echo lines in the first place seems weird, other than for testing and should have been removed anyway.