Hi all,
i am using kartik V FileInput extension i want to upload multiple files but its not working when i upload second file it replaces the first one
Here is my view
<?= $form->field($model, 'fld_image[]')->widget(FileInput::classname(), [
'pluginOptions' => [
'showCaption' => false,
'showRemove' => true,
'showPreview' => true,
'showUpload' => false,
'browseLabel' => ' ',
'removeLabel' => ' ',
'elCaptionText' => '#caption-photo',
],
'options' => [
'accept' => 'image/*',
'multiple'=>true,
]
]); ?>
Model
[['fld_name'], 'string', 'max' => 255],
[['fld_image'], 'file', 'extensions' => 'jpeg, jpg, png, gif', 'maxSize'=>20*1024*1024, 'maxFiles'=>1000],
Controller
$model->fld_image = UploadedFile::getInstances($model, 'fld_image');
// print_R($model->fld_image);exit;
$images = '';
if ($model->fld_image) {
foreach ($model->fld_image as $file) {
$img_name = Yii::$app->getSecurity()->generateRandomString();
$file->saveAs('uploads/' . $img_name . '.' . $file->extension);
$images .= $img_name.'.'.$file->extension.'###';
}
$model->fld_image = $images;
}
if any one has idea kindly correct me