gpt4 book ai didi

yii - CCAPTCHA 不显示图像 yii

转载 作者:行者123 更新时间:2023-12-01 17:35:34 25 4
gpt4 key购买 nike

我有一个用户注册表单,其中我尝试使用 Yii 小部件 CCaptcha 显示验证码图像,但是我的图像链接似乎已损坏, Controller 文件:

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

模型文件:

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

并查看文件:

<?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; ?>

作为某处提供的答案,我还尝试将 Controller 文件中的访问规则指定为

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

但似乎没有任何效果。

最佳答案

问题出在 Controller 文件上,它应该是,

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


虽然我在最后提到了验证码的操作,但我发现 Yii 中不允许这样做。 * 的所有允许操作应该在一起。

关于yii - CCAPTCHA 不显示图像 yii,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11895376/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com