Custom Validation
Write a custom validation function using onSelect. This demo rejects files with spaces in the name and files over 3 MB.
Drag & drop files here
<div id="myUploader" class="mu-uploader">...</div> <div id="validationMsg"></div>
var uploader = new MultipleUpload(document.getElementById('myUploader'), {
uploadUrl: '/api/upload',
onSelect: function(file) {
// Reject files with spaces in the name
if (/\s/.test(file.name)) {
showError(file.name + ': file names must not contain spaces.');
return false;
}
// Reject files over 3 MB
if (file.size > 3 * 1024 * 1024) {
showError(file.name + ': file exceeds 3 MB limit.');
return false;
}
return true;
}
});