From 99d481d69f27d73b1c117135ba187bd8bd31418b Mon Sep 17 00:00:00 2001 From: Omar Ahmed Hassan <98468609+omar-ahmed42@users.noreply.github.com> Date: Fri, 29 Nov 2024 14:22:52 +0200 Subject: [PATCH] Fix Array.from syntax in nonmultiple file upload (#2357) - Fix Array.from syntax in nonmultiple file upload as Array.from() returns an empty array which is the case when a file is selected from an input element (when multiple attribute isn't supported) which can be found in Array.from(element.files[0]) -> results in an empty array. --- src/main/resources/static/js/fileInput.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/static/js/fileInput.js b/src/main/resources/static/js/fileInput.js index 1e537dfc7d5..671bb039a76 100644 --- a/src/main/resources/static/js/fileInput.js +++ b/src/main/resources/static/js/fileInput.js @@ -86,7 +86,7 @@ function setupFileInput(chooser) { if (element instanceof HTMLInputElement && element.hasAttribute("multiple")) { allFiles = isDragAndDrop ? allFiles : [... allFiles, ... element.files]; } else { - allFiles = Array.from(isDragAndDrop ? allFiles : element.files[0]); + allFiles = Array.from(isDragAndDrop ? allFiles : [element.files[0]]); } if (!isDragAndDrop) {