kartik-v / bootstrap-fileinput

An enhanced HTML 5 file input for Bootstrap 5.x/4.x./3.x with file preview, multiple selection, and more features.
http://plugins.krajee.com/file-input
Other
5.36k stars 2.4k forks source link

How to delete newly downloaded files? #1864

Closed muramidaza closed 3 months ago

muramidaza commented 3 months ago

I used FileInput with the ability to download via Ajax. The file is added and uploaded to the server. When I click the Delete button, the file is also deleted from the panel, but no request is sent to the server. When the page is loaded, the initial (already downloaded files) are added - from there they are deleted normally by Ajax. How to make sure that when a file is deleted, a deletion request is sent to the server.

$fileForm = $form->field($requestFilesForm, 'uploadFiles[]')->widget(FileInput::class, [ 'language' => 'ru', 'options' => [ 'multiple' => true, 'accept' => '', ], 'pluginOptions' => [ 'previewFileType' => 'image', 'deleteUrl' => Url::to(['delete-file'],true), 'uploadUrl' => $model->id ? Url::to(['upload-files', 'id' => $model->id]) : null, 'uploadExtraData' => [ 'id' => $model->id, ], 'overwriteInitial' => false, 'showPreview' => true, 'initialPreview' => $files, 'initialPreviewFileType' => 'image', 'initialPreviewAsData' =>true, 'initialPreviewConfig' => $initialPreviewConfig, 'pluginEvents' => [ "fileuploaded" => "function(event, data, previewId, index) { console.log(data) }", ], 'maxFileSize' => 50000 ], ])->label('Прикрепленные файлы');