I found a setting that set limit for a single file
validation: {
sizeLimit: 51200 // 50 kB = 50 * 1024 bytes
}
How to implement validation as follows: any number can be uploaded to server but grand total must be less than 5mb ?
I found a setting that set limit for a single file
validation: {
sizeLimit: 51200 // 50 kB = 50 * 1024 bytes
}
How to implement validation as follows: any number can be uploaded to server but grand total must be less than 5mb ?
The best way to do this is to make use of the onValidate callback. There, you can keep a running total of all submitted file sizes. Once you reach your max, you can start rejecting files. For example:
var totalAllowedSize = 5000000,
totalSizeSoFar = 0;
callbacks: {
onValidate: function(data) {
if (totalSizeSoFar + data.size > totalAllowedSize) {
return false;
}
totalSizeSoFar += data.size;
}
}
Just wanted to share with my final solution for 'fineuploader' with jquery wrapper.
var totalAllowedSize = 10 * 1024 * 1024;
var totalSizeSoFar = 0;
var fuUrl = '[endpoint]';
$('#jquery-wrapped-fine-uploader').fineUploader({
request: {
endpoint: fuUrl
}
}).on('complete', function (event, id, name, response) {
__doPostBack('<%=btnUpdateClientAttachments.ClientID%>', null);
}).on("validate", function (event, obj) {
var fSize = obj[0].size;
if (totalSizeSoFar + fSize > totalAllowedSize) {
alert("Attachments attached to your email are over 10mb, please add link to your attachments instead");
return false;
}
totalSizeSoFar += fSize;
});
PS Thanks again to Ray for idea
I don't think fine uploader has that option (I don't use it). If you are using php, you can set the maximum POST size in your php.ini file. link
Why use fin uploader when you can fairly easily create your own and control everything? Am I the only one who wants to control everything?