Вид
<?php $form = ActiveForm::begin([
'options' => ['enctype'=>'multipart/form-data']
]); ?>
<?= $form->field($model, 'image')->widget(\dosamigos\fileinput\BootstrapFileInput::className(), [
'options' => ['accept' => 'image/*', 'multiple' => true],
'clientOptions' => [
'previewFileType' => 'text',
'browseClass' => 'btn btn-success',
'uploadClass' => 'btn btn-info',
'removeClass' => 'btn btn-danger',
'removeIcon' => '<i class="glyphicon glyphicon-trash"></i> '
]
]);?>
<?php echo Html::submitButton('Update') ?>
<?php ActiveForm::end(); ?>
контроллер
public function actionTest()
{
$dir = Yii::getAlias('@frontend/../web/uploads/test/');
$uploaded = false;
$model = new Test();
echo '<pre>';
print_r($_POST);
echo '</pre>';
if ($model->load($_POST)) {
$file = UploadedFile::getInstance($model, 'image[]');
echo '<pre>';
print_r($file);
echo '</pre>';
die();
/*
$model->image = $file;
if ($model->validate()) {
$uploaded = $file->saveAs( $dir . $file->name );
}*/
}
return $this->render('test',[
'model' => $model,
'uploaded' => $uploaded,
'dir' => $dir,
]);
}
Результат:
Array
(
[_csrf] => amwuNnIuaXNeKhlDNhYFITgtZ2E5STw4AgofRkN/DgUBDkpcLXw7Ng==
[Test] => Array
(
[image] =>
)
)
Подскажите, пожалуйста, почему не могу получить массив данных файлов?