can't see Captcha image

depending what php version and operating system you using:

for windows:

[list=1]

[*]locate your php.ini at C:\php\php.ini

[*]uncomment this line extension=php_gd2.dll

[*]restart your apache server

[/list]

for linux:

[list=1]

[*]is even simpler, install php-gd2 package

[*]restart your apache server

[/list]

Hello every body !

I have the same problem, but my GD extension is installed correctly :

my user models :


 <?php

class user extends CActiveRecord

{

	public $verifyCode;

[...]


public function rules()

	{

		// NOTE: you should only define rules for those attributes that

		// will receive user inputs.

		return array(

			array('verifyCode', 'captcha', 'allowEmpty'=>!extension_loaded('gd')),

[...]


public function attributeLabels()

	{

		return array(

			'verifyCode'=>'Code de verification',


[...]

?>

my UserController :


<?php


[...]

public function actions()

			{

					return array(

							'captcha'=>array(

									'class'=>'CCaptchaAction',

									'backColor'=>0xEBF4FB,

							),

					);

			}

[...]


?>



and my _form




	<?php if(extension_loaded('gd')): ?>

	<div class="row">

		<?php echo $form->labelEx($model,'verifyCode'); ?>

		<div>

		<?php $this->widget('CCaptcha'); ?>

		<?php echo $form->textField($model,'verifyCode'); ?>

		</div>

		<div class="hint">Veuillez retapez les lettres que vous voyer sur l'image.

		<br/>Les caractères ne sont pas sensible à la case.</div>

	</div>

	<?php endif; ?>



Where is problem ?

What happens if you call the captcha action directly? Like with index.php?r=<yourcontrollername>/captcha

I have an error :

But in my controllers dir i have a file who is name is "UserController.php"

should be:

index.php?r=user/captcha

it’s work !!

But i have an other error :

I am not authorized to see it !

Yes, you have to allow all users to see it in your accessRules() method.

it’s work,

Thanks for your help !

I also have a problem with captcha. I see the input field and "reload captcha" link, but I do not see the image itself. When I look into HTML source of generated page, <img> tag is there, but it has a problem with rendering image.

I have tried everything you advice here, Guys, and it still does not work… So:

  • I do have GD module loaded. There is a condition

 if (extension_loaded('gd'))

before showing any part of this.

  • I do have an action defined in controller and I do have permissions for it.

  • When I try to open index.php?r=<yourcontrollername>/captcha I do not see 403 but an image broken while rendering. (Chrome shows a missing image icon. Firefox shows information: "image can not be displayed, because it contains errors".) So it is not a permission issue.

And now the strangest part: I have captcha used in the other part of the site (yii-user extension) and… it works perfectly. Of course everything: view, controller are pretty much the same.

I really have no idea what is going wrong. Any guesses?

if you speek french :

Thanks. I do not speak French, unfortunately, but as far as I understood this is more or less what is described here: http://saptarshi.org/post/6/Yii%3A+Adding+captcha+to+comments.htm The problem is that I have exactly followed this instructions and it is not working…

OK, I know what is the reason. It is the charset issue.

I have to use URF-8 in my application. When I change the coding of a file to UTF-8 captcha is not working. When I change it back to ANSI – it is ok again.

Any ideas how to solve it?

Make sure the charset is UTF-8 without BOM.

Perfect! Thanks a lot :)

Hi guys,

I do have a same problem and did follow all above step by step codes and still having same problem.

I also have this …blogdemo-enhanced application installed and it shows image on that form and I did compare word by word in all …Model…Controller…Views but still image doesn’t show up on my another application Comment Form.

But there is one thing on my blog application Contact form the image shows up but on Comment Form doesn’t.

I spend the whole day to find it out but finally give up…:)

Any other reason where I’m missing some thing.

An early reply will be appreciated.

Hi guys,

Finally I just did figure out why Captcha image doesn’t show up on my comment form as I did follow step by step code in Controller, Modell and View.

The problem I found out in urlManager’=>array(…) in main.php file I just disable the entire block and wola it works then I manage my URL the way I want and then enable urlManager’=>array(…) and now every things working fine.

So make it sure that your URL are ok as still I didn’t gone through in deep in this problem as why it happened so make also sure the above post solution as it also caused by with some guys.

Good luck :)

Hello. I have the same problem. I have tried all solutions presented here. I use Unicode (UTF-8, no BOM) I have also zaped Gremlins just in case there could be any ASCII in there, but I didn’t find any. I also have tried to change the encoding scheme from ASCII to UTF 8 and back. with and without boom (original encoding was UTF-8, no boom). The blog application that follows the yii installation has a captcha that works and when i move the demo Blog to my webserver it works with captcha out of the box, but not from the same webserver on my new site.

I get this message in firefox when trying to call captcha alone from the site controller:

The gd library is installed with TTF support:

I get no errors in the log or when calling tail -f /var/log/apache2/error_log .

Any help would be appreciated.

I solved it. I must have been editing the index.php file with another editor. In the end it was a line break that I added in the index file between…

$yii=dirname(FILE).’/../../yii/framework/yii.php’;

and…

$config=dirname(FILE).’/protected/config/main.php’;

Such a subtle and invisible mistake. I am not sure if it is due to a change between ASCII and UTF8 or the change from Windows oriented line breaks to Unix, but I think it was the editor. I have been changing editors during the last weeks so that might explain it.

Be careful about the text encoding boys and girls.

So many people have different kinds of problems with captcha that we can create a special topic in the guide (or better cookbook page) about this :D

I have bad experience with cpatacha image before but I found the solution around many issues depend on your settings but the

first and big reason which affect capatcha image is the encoding of index.php for intro run page , main.php in config folder you should encode it with utf-8 with out BOM , I used notepad++ to did that .

second reason : the access rules . but when I CHECK other demos test i did not find any related access rules with capatcha .