mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-05-22 09:52:01 +00:00
Fix allowing multiple files to be dropped onto a single file input (#2359)
Fix a bug that allowed multiple files to be dropped onto a single-file input element - Fix a bug that allowed multiple files to be dropped onto a single-file input element by accepting only the first file.
This commit is contained in:
parent
25e564154e
commit
de23bb702c
@ -47,14 +47,16 @@ function setupFileInput(chooser) {
|
|||||||
const dt = e.dataTransfer;
|
const dt = e.dataTransfer;
|
||||||
const files = dt.files;
|
const files = dt.files;
|
||||||
|
|
||||||
for (let i = 0; i < files.length; i++) {
|
const fileInput = document.getElementById(elementId);
|
||||||
allFiles.push(files[i]);
|
if (fileInput?.hasAttribute("multiple")) {
|
||||||
|
files.forEach(file => allFiles.push(file));
|
||||||
|
} else if (fileInput) {
|
||||||
|
allFiles = [files[0]];
|
||||||
}
|
}
|
||||||
|
|
||||||
const dataTransfer = new DataTransfer();
|
const dataTransfer = new DataTransfer();
|
||||||
allFiles.forEach((file) => dataTransfer.items.add(file));
|
allFiles.forEach((file) => dataTransfer.items.add(file));
|
||||||
|
|
||||||
const fileInput = document.getElementById(elementId);
|
|
||||||
fileInput.files = dataTransfer.files;
|
fileInput.files = dataTransfer.files;
|
||||||
|
|
||||||
if (overlay) {
|
if (overlay) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user