View:
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
echo $form->field($model, 'fileImage')->fileInput(['multiple' => true, 'accept' => 'image/*']);
Model :
public $fileImage;
public function rules()
{
return [
[['description_ru', 'description_en'], 'string', 'max' => 255],
[['fileImage'], 'file', 'maxFiles' => 5, 'skipOnEmpty' => true, 'extensions' => 'png, jpg, jpeg, gif'],
];
}
Controller :
public function actionCreate()
{
$model = new Works();
if ($model->load(Yii::$app->request->post())) {
if($_FILES){
echo '<pre>';
print_r($_FILES);
die();
}
if ($model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
Выбераю 3 картинки жму create , но в массив показывает одну картинку
Array
(
[Works] => Array
(
[name] => Array
(
[fileImage] => ubuntu_bubbles_linux_93773_1366x768.jpg
)
[type] => Array
(
[fileImage] => image/jpeg
)
[tmp_name] => Array
(
[fileImage] => /tmp/phpT7u4pN
)
[error] => Array
(
[fileImage] => 0
)
[size] => Array
(
[fileImage] => 171551
)
)
)