mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-07-25 22:55:22 +00:00
Enforce the limit on uploading
This commit is contained in:
parent
8110fef364
commit
187de811ee
@ -43,6 +43,14 @@
|
|||||||
firstErrorOccurred = false;
|
firstErrorOccurred = false;
|
||||||
const url = this.action;
|
const url = this.action;
|
||||||
let files = $('#fileInput-input')[0].files;
|
let files = $('#fileInput-input')[0].files;
|
||||||
|
const uploadLimit = window.stirlingPDF?.uploadLimit ?? 0;
|
||||||
|
if (uploadLimit > 0) {
|
||||||
|
const oversizedFile = Array.from(files).find(f => f.size > uploadLimit);
|
||||||
|
if (oversizedFile) {
|
||||||
|
alert(`"${oversizedFile.name}" is too large. Maximum allowed size is ${window.stirlingPDF.uploadLimitReadable}.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
const formData = new FormData(this);
|
const formData = new FormData(this);
|
||||||
const submitButton = document.getElementById('submitBtn');
|
const submitButton = document.getElementById('submitBtn');
|
||||||
const showGameBtn = document.getElementById('show-game-btn');
|
const showGameBtn = document.getElementById('show-game-btn');
|
||||||
|
@ -179,6 +179,18 @@ function setupFileInput(chooser) {
|
|||||||
|
|
||||||
await checkZipFile();
|
await checkZipFile();
|
||||||
|
|
||||||
|
const uploadLimit = window.stirlingPDF?.uploadLimit ?? 0;
|
||||||
|
if (uploadLimit > 0) {
|
||||||
|
const oversizedFile = allFiles.find(f => f.size > uploadLimit);
|
||||||
|
if (oversizedFile) {
|
||||||
|
alert(`"${oversizedFile.name}" is too large. Maximum allowed size is ${window.stirlingPDF.uploadLimitReadable}.`);
|
||||||
|
allFiles = [];
|
||||||
|
input.value = '';
|
||||||
|
inputContainer.querySelector('#fileInputText').innerHTML = originalText;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
allFiles = await Promise.all(
|
allFiles = await Promise.all(
|
||||||
allFiles.map(async (file) => {
|
allFiles.map(async (file) => {
|
||||||
let decryptedFile = file;
|
let decryptedFile = file;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user