CCaptcha显示没有图像yii

dib*_*_ab 6 captcha yii

我有一个用户注册表单,我试图通过使用Yii小部件CCaptcha显示Captcha图像,但是我的图像链接显示已损坏,控制器文件:

public function actions()
    {
        return array(
            // captcha action renders the CAPTCHA image displayed on the contact page
            'captcha'=>array(
                'class'=>'CCaptchaAction',
                'backColor'=>0xFFFFFF,
            ),
        );
    } 
Run Code Online (Sandbox Code Playgroud)

模型文件:

public function rules()
 {
    return array( array('verifyCode','captcha','allowEmpty'=>!CCaptcha::checkRequirements(),'on'=>'insert'), 
);
}
Run Code Online (Sandbox Code Playgroud)

并查看文件:

<?php if(CCaptcha::checkRequirements()): ?>
    <div class="row">
        <?php echo $form->labelEx($model,'verifyCode'); ?>
        <div>
        <?php $this->widget('CCaptcha'); ?>
        <?php echo $form->textField($model,'verifyCode'); ?>
        </div>
        <div class="hint">Please enter the letters as shown.
        <br/>Letters are not case-sensitive.</div>
        <?php echo $form->error($model,'verifyCode'); ?>
    </div>
    <?php endif; ?>
Run Code Online (Sandbox Code Playgroud)

作为某处提供的答案,我也尝试在我的控制器文件中提供访问规则

public function accessRules()
{
    return array(
        array('allow',
         'actions' => array('captcha'), 
         'users' => array('*'),
         ),
    );
}
Run Code Online (Sandbox Code Playgroud)

但似乎没有任何效果.

dib*_*_ab 8

问题出在控制器文件上,应该是,

public function accessRules()
    {
        return array(
            array('allow', 
                'actions'=>array('create', 'captcha'),
                'users'=>array('*'),
            ),
    } 
Run Code Online (Sandbox Code Playgroud)


虽然我最后提到了验证码的动作,但我认为Yii不允许这样做.*的所有允许操作应该在一起.