Answer the question
In order to leave comments, you need to log in
Why Bad Request image (#400) in yii2?
I am editing a post, when I click Save, I get an error Bad Request (# 400)
I found out that the error is due to the output of the picture, if this code is removed from the form view
<?php
$img = $image->getPostImg($model->id);
if(!empty($img->name)){
echo Html::img('https://site.ku/frontend/web/' . $img->name, $options = ['id' => 'blah', 'style' => ['width' => '180px']]);
}
?>
<?= $form->field($image, 'image')->fileInput(['id' => 'images-image', 'name' => 'Images[image]']) ?>
<img id="blah" src="https://site.ku/frontend/web/uploads/post/post_5bd33b14ab799.png" alt="" style="width: 180px;">
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['AdminPanel'],
],
],
],
Answer the question
In order to leave comments, you need to log in
Check if the form has a CSRF token. Most often, this error is precisely because of him. Especially if the logs say "failed to check the data."
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question