Home » Php » php – Yii2 kartik file upload widget issue

php – Yii2 kartik file upload widget issue

Posted by: admin February 25, 2020 Leave a comment

Questions:

i have created a fileupload using kartik file upload widget in yii2.And the widget code

<?=$form->field($model, 'file[]')->widget(FileInput::classname(), [
    'pluginOptions' => [
        'initialPreview'=>[
            "http://upload.wikimedia.org/wikipedia/commons/thumb/e/e1/FullMoon2010.jpg/631px-FullMoon2010.jpg",
            "http://upload.wikimedia.org/wikipedia/commons/thumb/6/6f/Earth_Eastern_Hemisphere.jpg/600px-Earth_Eastern_Hemisphere.jpg"
        ],
        'initialPreviewAsData'=>true,
        'initialCaption'=>"The Moon and the Earth",
        'initialPreviewConfig' => [
            ['caption' => 'Moon.jpg', 'size' => '873727'],
            ['caption' => 'Earth.jpg', 'size' => '1287883'],
        ],
        'showPreview'=>true,
        'showCaption' => false,
        'showRemove' => false,
        'showUpload' => false,
        'showCancel' => false,
        'browseClass' => 'btn btn-theme btn-lg btn-block',
        'browseIcon' => '<i class="glyphicon glyphicon-camera"></i> ',
        'browseLabel' =>  'Select Photo',
        'overwriteInitial'=>false
    ],
    'options' => ['accept' => 'image/*','multiple'=>true]
]);?>

Please check the below image to view the output
enter image description here

in image we can see that for the initial preview images there is move icon to move the image and we can arrange the position.But when i select another file it doesn’t have the move icon.
How can i add move button to the newly selected files.Because i don’t want to set initial Images

How to&Answers: