OnSelect Filter

Demo uploads land in a temporary store and are swept after 60 minutes. To keep files, handle FileUploaded — see Single File for the complete save pattern.
Filter Files in onSelect Callback

Use the onSelect callback to inspect and filter files before they enter the upload queue. Reject files based on custom criteria such as naming conventions or content checks.

What you should see: a custom rule applied at selection time: files can be inspected and rejected before they ever join the queue.
Rules: Only files under 5 MB with .jpg, .png, or .pdf extensions are accepted. Filenames containing spaces are rejected.
AjaxUploader.create('#uploader', {
 uploadUrl: '/ajaxupload.axd/upload',
 multiple: true,
 onSelect: function(files) {
 var allowed = ['.jpg', '.png', '.pdf'];
 var maxSize = 5 * 1024 * 1024;
 return files.filter(function(f) {
 var ext = f.name.substring(f.name.lastIndexOf('.')).toLowerCase();
 if (allowed.indexOf(ext) === -1) {
 log('Rejected (type): ' + f.name);
 return false;
 }
 if (f.size > maxSize) {
 log('Rejected (size): ' + f.name);
 return false;
 }
 if (f.name.indexOf(' ') !== -1) {
 log('Rejected (spaces in name): ' + f.name);
 return false;
 }
 log('Accepted: ' + f.name);
 return true;
 });
 }
});