Hi Toko,
Thank you for contacting Syncfusion support.
We have checked your requirement for adding limit to upload the file into uploader. We have two solution for this case.
Solution 1:
We have prepared sample based on your requirement, get the selected file length from “selected“ event and check the limit “count“. If the count is higher than the selected file then, call args.cancel and show error message. We have alerted the error message for maximum of 3 files to upload. Please find the sample for your reference.
onFileSelect(args) {
var fileLength = args.filesData.length + this.uploadObj.getFilesData().length;
if (fileLength > this.count) {
args.cancel = true;
document.getElementsByClassName('e-error')[0].innerHTML = 'maximum of ' + this.count + ' files to upload';
} else {
document.getElementsByClassName('e-error')[0].innerHTML = '';
}
} |
Solution 2:
if you need to exceed the file length and upload only the limited files use the below sample.
onFileSelect(args) {
var fileLength = args.filesData.length + this.uploadObj.getFilesData().length;
// if you need upload first 3 files means use this way.
if (fileLength > this.count) {
args.filesData.splice(this.count, args.filesData.length);
alert('maximum of ' + this.count + ' files to upload')
document.getElementsByClassName('e-error')[0].innerHTML = 'maximum of ' + this.count + ' files to upload';
} else {
document.getElementsByClassName('e-error')[0].innerHTML = '';
}
} |
Please let us know if you need any further assistance on this.
Regards,
Prince