Skip to content

Commit

Permalink
Merge pull request #5664 from Laravel-Backpack/fix-upload-multiple-fi…
Browse files Browse the repository at this point in the history
…le-selection

fix upload multiple selection display
  • Loading branch information
pxpm authored Sep 17, 2024
2 parents 0d79292 + e3a46e0 commit 7d0b79c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/resources/views/crud/fields/upload_multiple.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ function bpFieldInitUploadMultipleElement(element) {
fileInput.change(function() {
let selectedFiles = [];
let existingFiles = fileInput.parent().siblings('.existing-file');
Array.from($(this)[0].files).forEach(file => {
selectedFiles.push({name: file.name, type: file.type})
Expand All @@ -231,11 +232,11 @@ function bpFieldInitUploadMultipleElement(element) {
selectedFiles.forEach(file => {
files += '<span class="badge mt-1 mb-1 text-bg-secondary badge-primary">'+file.name+'</span> ';
});
// if existing files is not on the page, create a new div a prepend it to the fileInput
if(existingFiles.length === 0) {
existingFiles = $('<div class="well well-sm existing-file mb-2"></div>');
existingFiles.insertBefore(element.find('input[type=hidden]'));
existingFiles.insertBefore(element.find('input[type=hidden]').first());
existingFiles.html(files);
}else {
// if existing files is on page show the added files after the uploaded ones
Expand Down

0 comments on commit 7d0b79c

Please sign in to comment.