So, I had this same issue. The way to detect it on Chrome is to look for data.originalFiles.length > 1, and on Firefox you want to look for data.files[0].size === 0.
I tried playing around with setting the options for minFileSize: 1, maxNumberOfFiles: 1 (and setting getNumberOfFiles too!), singleFileUploads: false, and limitMultiFileUploads: 1... but none of them seemed to work very well, and the documentation was kind of fuzzy and the code a bit convoluted.
They do have an option for validations (https://github.com/blueimp/jQuery-File-Upload/wiki/Options#processqueue), but the example uses the deprecated $.Deferred method in jQuery.
So, I ended up doing something like this (I removed all of my custom stuff and extras to make it a little more simple/to the point):
var jqXHR = null;
$('#fileupload').fileupload({
multipart: false,
add: function(e, data) {
if (data.originalFiles.length > 1 || data.files[0].size === 0) {
fileError(null, 'zip');
} else {
jqXHR = data.submit();
}
},
error: function(jqXHR, textStatus) {
self.fileError(jqXHR, textStatus);
}
});
var fileError = function(jqXHR, textStatus) {
var statusCode = jqXHR ? jqXHR.status : 0;
// Figure out something nice to say, then close modal and clear out input box.
var friendlyError = 'Your file failed to upload.';
if (textStatus === 'abort') {
friendlyError = 'Your file upload was aborted.';
} else if (textStatus === 'error') {
friendlyError = 'There was a server error that prevented your file from being uploaded.';
} else if (textStatus === 'zip') {
friendlyError = 'This file cannot be uploaded. Please zip the file and try again.';
}
// Your custom UI code here!
};
Basically, if it's got more than one file or the file size is 0, trigger the error code instead of submitting the jqXHR data. Then, override the error handling in fileupload to also use this error handler, because DRY.
file.type(aka ContentType) for some files types (zip, doc, xls) inside folders. It will set thefile.typeto an empty string.