R
R
Ruslan2017-08-17 14:19:21
Yii
Ruslan, 2017-08-17 14:19:21

Why does the captcha not see a method for uploading an image?

Good day. There is a Site controller, it contains the code:

public function actions()
    {
        return [
            'captcha' => [
                'class' => 'yii\captcha\CaptchaAction',
                'width' => 132,
                'height' => 39,
                'backColor' => 0xFFFFFF,
                'foreColor' => 0xBABABA,
                'minLength' => 6,
                'maxLength' => 7,
                'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
            ],
        ];
    }

The model used for the view form has a public $verifyCode field; and in the rules:
['verifyCode', 'captcha', 'captchaAction' => '/site/captcha'],

The view has the code:
<div class="form">
        <?php
        $form = ActiveForm::begin([
                'id' => 'one-form',
                'enableAjaxValidation' => true,
                'enableClientValidation' => false,
                'validateOnSubmit' => true,
                'scrollToError' => false,
                'fieldConfig' => [
                    'template' => '{input}',
                ]
        ]);
        ?>
............................................
<div class="input-wrap captcha-s">
                <?=
                $form->field($model, 'verifyCode', ['enableAjaxValidation' => false,])->widget(Captcha::className(), [
                    'captchaAction' => Url::toRoute('captcha'),
                    'template' => '<div class="row"><div class="col-sm-8">{input}</div><div class="col-sm-4"><div class="img-s">{image}</div></div></div>',
                    'options' => [
                        'class' => 'form-control',
                        'autocomplete' => 'off',
                        'placeholder' => $model->getAttributeLabel('verifyCode'),
                        'style' => 'text-align: center;',
                    ],
                ])->label('Please enter the security code:<span class="red">*</span>')
                ?>
            </div>
...................................................

        <?php ActiveForm::end(); ?>

        ...........................................
    </div>

But when I open the page, the captcha image is NOT loaded, and it throws an error in the console: GET site.loc/site/captcha?v=599572d477939
404 (Not Found) ............ than the problem............ Thanks in advance everyone

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question