I have this little problem in uploading multiple images using yii2 and Kartik fileInput extension.
this is the model:
public $file;
public static function tableName()
{
return 'news';
}
public function rules()
{
return [
[['news_desc', 'news_context', 'news_first_source', 'news_second_source', 'news_third_source', 'news_responsibe_party', 'news_first_testimony', 'news_second_testimony', 'news_body', 'news_lang'], 'string'],
[['news_gov_id', 'news_typ_id', 'news_is_in_slider', 'news_is_act', 'news_is_del'], 'integer'],
[['news_happened_date', 'news_created_date', 'file'], 'safe'],
[['news_typ_id', 'news_lang'], 'required'],
[['news_title'], 'string', 'max' => 255],
[['file'], 'file','maxFiles' => 6],
];
}
as you can notice I am using maxFiles but it didnt worked for me
Controller:
public function actionCreate_news()
{
$model = new News();
if ($model->load(Yii::$app->request->post())) {
$model->file = UploadedFile::getInstances($model, 'file');
var_dump($model->file);
die();}}
right now I am just var dump the files I get but the problem there is only one file not all the files i uploaded
view:
echo FileInput::widget([
'model' => $model,
'attribute' => 'file[]',
'name' => 'file[]',
'options' => [
'multiple' => 'true',
'accept' => 'image/*'
],
'pluginOptions' => [
'showCaption' => false,
'showRemove' => false,
'showUpload' => false,
'allowedFileExtensions' => ['jpg','jpeg','png'],
'overwriteInitial' => false
],
]);
i have read all things about this issue and tried all the possible solutions but the problem is still there
when i press submit for the form only the last file will be submited
thanks