Пытаюсь отправить форму, но почему-то вылезает ошибка типа - "Файл не выбран", а хотя файл выбран
Model:
Код: Выделить всё
public function rules() {
return [
[['file', 'content', 'author', 'email'], 'required'],
[['content'], 'string'],
['email', 'email'],
[['file'], 'file', 'extensions' => ['jpg', 'jpeg', 'png', 'gif']],
[['author', 'email', 'link'], 'string', 'max' => 255]
];
}
Код: Выделить всё
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>
<?= $form->field($model, 'file')->fileInput(); ?>
<?= $form->field($model, 'content')->textArea(['rows' => '6']); ?>
<?= $form->field($model, 'author'); ?>
<?= $form->field($model, 'email'); ?>
<?= $form->field($model, 'link'); ?>
<?= Html::submitButton('Submit', ['class' => 'btn btn-success']); ?>
<?php ActiveForm::end(); ?>
Код: Выделить всё
public function actionSend() {
$model = new UserNews;
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
print_r($model);
die();
return $this->refresh();
} else {
return $this->render('send', [
'model' => $model,
]);
}
}