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;
|
const uploadLimit = window.stirlingPDF?.uploadLimit ?? 0;
|
||||||
if (uploadLimit > 0) {
|
if (uploadLimit > 0) {
|
||||||
const oversizedFile = allFiles.find(f => f.size > uploadLimit);
|
const oversizedFiles = allFiles.filter(f => f.size > uploadLimit);
|
||||||
if (oversizedFile) {
|
if (oversizedFiles.length > 0) {
|
||||||
alert(`"${oversizedFile.name}" ${window.stirlingPDF.uploadLimitExceeded} ${window.stirlingPDF.uploadLimitReadable}.`);
|
const names = oversizedFiles.map(f => `"${f.name}"`).join(', ');
|
||||||
allFiles = [];
|
|
||||||
input.value = '';
|
if (names.length === 1) {
|
||||||
inputContainer.querySelector('#fileInputText').innerHTML = originalText;
|
alert(`${names} ${window.stirlingPDF.uploadLimitExceededSingular} ${window.stirlingPDF.uploadLimitReadable}.`);
|
||||||
return;
|
} 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