Enforce allowed filesize and type in extra var upload form

This commit is contained in:
Kijin Sung 2024-10-09 11:36:14 +09:00
parent 7fe2203cbd
commit 3ffeb63afb
3 changed files with 23 additions and 2 deletions

View file

@ -11,6 +11,15 @@
});
$('input.rx_ev_file').on('change', function() {
const container = $(this).parents('.ev_file_upload');
const max_size = parseInt($(this).data('allowedFilesize'), 10);
const file_count = this.files.length;
for (let i = 0; i < file_count; i++) {
if (max_size && this.files[i].size > max_size) {
alert($(this).data('msgFilesize'));
$(this).val('');
return;
}
}
container.find('input[type=hidden][name^=_delete_]').val('N');
});
});