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

Prevent deleting uploaded files using ajax/server uploads / initialPreviewShowDelete: false not working #1482

Closed g-wilkinson closed 4 years ago

g-wilkinson commented 5 years ago

Prerequisites

Steps to reproduce the issue

  1. initialPreviewShowDelete set to false
  2. File upload set to auto upload using filebatchselected event
  3. The "remove file" button is still displayed

File-Upload-Hide-Delete-button-on-preview

Expected behavior and actual behavior

Once a file has been uploaded we do not want the ability for end users to delete the file.

When I follow those steps, I see... the "Remove file" button

I was expecting... not to see the "Remove file" button

I have not been able to reproduce on the demo site as have not found an example that uses initialPreviewShowDelete but the following is similar to what we are using: https://plugins.krajee.com/file-input-ajax-demo/6

Is my understanding of using initialPreviewShowDelete correct or is there another option to use?

Plugin options are:

theme: 'fas', 
overwriteInitial: 0, 
uploadAsync: 1, 
showUpload: 0, 
showRemove: 0, 
initialPreviewAsData: 1, 
initialPreviewShowDelete: 0, 
validateInitialCount: 1, 
uploadUrl: '/ajax/upload.php', 
allowedFileExtensions: [ "pdf", "png", "gif", "jpg", "doc", "docx", "odf" ],
maxFileCount: 20,

Environment

Browsers

Operating System

Libraries

Isolating the problem

g-wilkinson commented 5 years ago

I have updated the screen shot to indicate the issue. i.e. the first two uploads are previews that have already been uploaded to server so we don't want the Remove button to show for these (as highlighted with the magenta box).
The last upload/on the right has just been uploaded so is correctly showing the Remove button.

kartik-v commented 4 years ago

Fixed via above commit.