验证码不能以yii显示图像

时间:2015-10-28 10:07:05

标签: php yii captcha yii-components

我在视图页面中尝试了CAPTCHA代码,

模型规则

public function rules()
    {
        return array(
             array('verifyCode', 'captcha', 'allowEmpty'=>extension_loaded('gd')),
        );
    }

以下有关视图页面控件的代码..

<?php if(extension_loaded('gd')): ?>
            <div class="row">
                <?php echo $form->labelEx($model,'verifyCode'); ?>
                <?php echo $form->textField($model,'verifyCode'); ?>
                <div>
                    <?php $this->widget('CCaptcha'); ?>
                </div>
                <div class="hint">Please enter the letters as they are shown in the image above.
                <br/>Letters are not case-sensitive.</div>
            </div>
        <?php endif; ?>

控制器操作

public function actions()
    {
        return array(
            'captcha'=>array(
                'class'=>'CCaptchaAction',
                'backColor'=>0xFFFFFF,
            ),

            'page'=>array(
                'class'=>'CViewAction',
            ),
        );
    }

和控制器访问规则..

public function accessRules()
        {
            return array(
                array('allow', 
                    'actions'=>array('index','view','create','captcha'),
                    'users'=>array('*'),
                    )
                );
        } 

但不显示任何Imgae, 帮助将是适当的。

0 个答案:

没有答案