3

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 ?

f0rza
  • 480
  • 3
  • 17

3 Answers3

3

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;
    }
}
Ray Nicholus
  • 19,538
  • 14
  • 59
  • 82
0

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

f0rza
  • 480
  • 3
  • 17
  • No need to use `.on` to contribute event handlers in your case. Probably more efficient to use my example. – Ray Nicholus Aug 14 '14 at 19:42
  • I'm still using in project fine uploader v.3 and did not get to code at 'onValidate' function. That's why rewrote it a bit – f0rza Aug 17 '14 at 14:57
-3

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?

Community
  • 1
  • 1
Marcel
  • 1,034
  • 1
  • 17
  • 35
  • 2
    This is not really a helpful answer _at all_. The question was tagged `fine-uploader`, and you -- more or less -- provided your opinion as an answer. Also, I disagree that it is easy to create your own uploader (https://github.com/widen/fine-uploader/issues?q=is%3Aissue+is%3Aclosed). – Mark Feltner Aug 13 '14 at 15:50
  • 1
    Fair point. I did however give a solution (hack) to the problem. I will refrain from giving my opinion as a solution in the future. – Marcel Aug 13 '14 at 16:03
  • Also, your solution is not useful. You are making the assumption that all files are sent in one request - not true. – Ray Nicholus Aug 13 '14 at 17:17
  • Well sorry for trying to be helpful. Next time I see a question whose topic in which I am not an expert (all of them), I will just ignore it. Is that what you want? – Marcel Aug 13 '14 at 17:28
  • Instead of providing incorrect advice? yes, please do – Ray Nicholus Aug 13 '14 at 17:52
  • Maybe next time it won't be incorrect advice though. – Marcel Aug 13 '14 at 18:09