Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
143409 | Mar 19,2019 01:59 PM UTC | Mar 20,2019 04:54 PM UTC | React - EJ 2 | 1 |
![]() |
Tags: Uploader |
Hello,
I am currently
using the Uploader component to upload my files to the server. the problem is
that I can not limit the number of files to upload. I would like the user to
have a maximum of 3 files to upload and return an error message if he tries to
add more than 3.
Thanks in advance and regards,
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 = '';
}
} |
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 = '';
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.