mirror of
https://github.com/itflow-org/itflow
synced 2026-03-24 06:25:40 +00:00
Create some javascript that limits the amount of files to 20 that can be uploaded at once.
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
<div class="modal-body bg-white">
|
||||
|
||||
<div class="form-group">
|
||||
<input type="file" class="form-control-file" name="file[]" multiple accept=".jpg, .jpeg, .gif, .png, .webp, .pdf, .txt, .md, .doc, .docx, .odt, .csv, .xls, .xlsx, .ods, .pptx, .odp, .zip, .tar, .gz, .xml, .msg, .json, .wav, .mp3, .ogg, .mov, .mp4, .av1">
|
||||
<input type="file" class="form-control-file" name="file[]" multiple id="fileInput" accept=".jpg, .jpeg, .gif, .png, .webp, .pdf, .txt, .md, .doc, .docx, .odt, .csv, .xls, .xlsx, .ods, .pptx, .odp, .zip, .tar, .gz, .xml, .msg, .json, .wav, .mp3, .ogg, .mov, .mp4, .av1">
|
||||
</div>
|
||||
<small class="text-secondary">Multiple files can be uploaded by holding down CTRL and selecting files</small>
|
||||
|
||||
@@ -25,3 +25,29 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const maxFiles = 20; // Set the maximum number of allowed files
|
||||
|
||||
const fileInput = document.getElementById('fileInput');
|
||||
const uploadForm = document.getElementById('uploadForm');
|
||||
|
||||
fileInput.addEventListener('change', function () {
|
||||
if (fileInput.files.length > maxFiles) {
|
||||
alert(`You can only upload up to ${maxFiles} files at a time.`);
|
||||
resetFileInput();
|
||||
}
|
||||
});
|
||||
|
||||
uploadForm.addEventListener('submit', function (event) {
|
||||
if (fileInput.files.length > maxFiles) {
|
||||
event.preventDefault();
|
||||
alert(`You can only upload up to ${maxFiles} files at a time.`);
|
||||
resetFileInput();
|
||||
}
|
||||
});
|
||||
|
||||
function resetFileInput() {
|
||||
fileInput.value = ''; // Clear the selected files
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user