mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-06-06 18:30:57 +00:00
Allow for non-offending files to still be uploaded
This commit is contained in:
parent
97a3a7e8c0
commit
7dc707c185
@ -181,13 +181,26 @@ function setupFileInput(chooser) {
|
||||
|
||||
const uploadLimit = window.stirlingPDF?.uploadLimit ?? 0;
|
||||
if (uploadLimit > 0) {
|
||||
const oversizedFile = allFiles.find(f => f.size > uploadLimit);
|
||||
if (oversizedFile) {
|
||||
alert(`"${oversizedFile.name}" ${window.stirlingPDF.uploadLimitExceeded} ${window.stirlingPDF.uploadLimitReadable}.`);
|
||||
allFiles = [];
|
||||
input.value = '';
|
||||
inputContainer.querySelector('#fileInputText').innerHTML = originalText;
|
||||
return;
|
||||
const oversizedFiles = allFiles.filter(f => f.size > uploadLimit);
|
||||
if (oversizedFiles.length > 0) {
|
||||
const names = oversizedFiles.map(f => `"${f.name}"`).join(', ');
|
||||
|
||||
if (names.length === 1) {
|
||||
alert(`${names} ${window.stirlingPDF.uploadLimitExceededSingular} ${window.stirlingPDF.uploadLimitReadable}.`);
|
||||
} else {
|
||||
alert(`${names} ${window.stirlingPDF.uploadLimitExceededPlural} ${window.stirlingPDF.uploadLimitReadable}.`);
|
||||
}
|
||||
|
||||
allFiles = allFiles.filter(f => f.size <= uploadLimit);
|
||||
|
||||
const dataTransfer = new DataTransfer();
|
||||
allFiles.forEach(f => dataTransfer.items.add(f));
|
||||
input.files = dataTransfer.files;
|
||||
|
||||
if (allFiles.length === 0) {
|
||||
inputContainer.querySelector('#fileInputText').innerHTML = originalText;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user