Why not load all files if they are to drag and drop one file into the field?

There is a possibility to attach files to a post. The attachment is carried out using the widget https://github.com/kartik-v/yii2-widget-fileinput
If you select several files and drag them to the box load, all works well. If you drag and drop files one at a time, for some reason only loads the last file, the rest are just lost. Why is this happening and how to fix it?
The procedure is: fill in the desired fields, drag the file, press the save button. (The files themselves do not press download). The procedure for this, because I do not want the files to uploaded without established post.
The code in the controller:
public function actionCreate()
{
 $model = new Article(); //Create model post
 $upload = new UploadForm(); // Create model file downloads

 if (Yii::$app->request->isPost) {
 $model->load(Yii::$app->request->post()); //Load data into model
 if($model->save()){ 
 $upload->files = UploadedFile::getInstances($upload, 'files'); // If the model is saved, then load the file
 $upload->an uploadoperation($model->id); //Save files and for each file create a record in the table
 return $this->redirect(['view', 'id' => $model->id]);
}
}
 return $this->render('create', compact('model','categories','upload'));
 }

Model download files:
public $files;
 public function rules()
{
 return [
 [['files'], 'file', 'maxSize'=>8*1024*1024,'maxFiles' => 10],
];
}
 public function an uploadoperation($article_id){
 $user_id= Yii::$app->user->id;
 foreach ($this->files as $file) {
 $filename = $this->generateFilename($file); //Generate file name
 $file->saveAs($this->getFolder() . $filename); //Save the file

 $operation= new Uploads(); //Create an entry in the database table
 $operation->user_id=$user_id; //Who loaded the file
 $operation->article_id=$article_id; //To which the post belongs
 $operation->file=$filename; //file Path
if($operation->validate()){
 $operation->save(false); //Save the recording
}
else{
 unlink($this->getFolder().$filename); //Removes the file
 throw new ForbiddenHttpException('Wrong Upload');
}
}
}
}

Himself view:
<?php $form = ActiveForm::begin(
['options'=-->['enctype'=>'multipart/form-data']]
 ); ?>

 <?= $form--->field($model, 'content')->textarea(['rows' => 6]) ?> // The contents of the post
<?= $form--->field($upload, 'files[]')->widget(FileInput::className(), [ 
 'language' => 'EN',
 'options' => ['multiple' => true],
 'pluginOptions' => ['uploadUrl' => Url::to(['There is just a plug, because files are loaded after the creation of the post'])] 
 ]); ?>
 <div class="form-group">
 <?= Html::submitButton('Save', ['class' =--> 'btn btn-success']) ?> //Create a post
</div>
 <?php ActiveForm::end(); ?>
June 8th 19 at 17:17
0 answer

Find more questions by tags YiiAJAX