-1

I have a question about the plupload queue

I want to know where i can put the maximum file upload so i only wants that a user uploads files with a mixmum of 1gb total so by example 10 files of 100mb is total 1gb and after this the user dont cant upload files any

$(document).ready(function () {

    $(function () {
        $("#uploader").pluploadQueue({
            runtimes: 'html5, html4',
            url: '/Upload/Upload',
            max_file_size: '1gb',
            unique_names: true,
            multipart: true,
            multiple_queues: false,
            filters: [
                { title: "Bestanden", extensions: "jpg,gif,png,docx,wmv,xslx,avi" },
            ],

            preinit: {
                FileUploaded: function (up, file, response) {
                    var data = response.response; //$.parseJSON(response.response);

                    $('<input>').attr({
                        type: 'hidden',
                        name: 'fileId' + data,
                        value: data
                    }).appendTo('#uploadFinishedForm');

                    if (data.error == 1) {
                        uploader.trigger("Error", { message: "'" + data.message + "'", file: file });
                        console.log('[Error] ' + file.id + ' : ' + data.message);
                        return false;
                    }
                },

                UploadComplete: function (up, files) {
                    window.setTimeout(function (form) {
                 //       $('#uploadFinishedForm').submit();
                        $('.nextButton').append('<input type="submit" class="btn btn-large btn-success submit-btn" value="Transfer" />');
                    }, 2000)

                },

                Init: function (up, info) {
                    $('#uploader_container').removeAttr("title");
                }
            }
        });


        $('#uploadForm').submit(function (e) {
            var uploader = $('#uploader').pluploadQueue();
            if (uploader.files.length > 0) {
                uploader.bind('StateChanged', function () {
                    if (uploader.files.length === (uploader.total.uploaded + uploader.total.failed)) {
                        $('#uploadForm').submit();
                    }
                });

                uploader.start();
            } else {
                $('#uploadInfo').html('Zonder foto\'s valt er niets te uploaden!');
            }

            return false;



        });

        $(".btnDel")
                .live("click", function () {
                    if ($("tr.person-input-row").length > 1) {
                        if (confirm("Wilt u deze naam wilt verwijderen?")) {
                            $(this).parents("tr.person-input-row").fadeOut("normal", function () { $(this).remove(); refineIndexes(); });
                        }
                    } else {
                        alert("Naam kan niet worden verwijderd.\n\nEr dient minimaal 1 email adres opgegeven te worden.");
                    }
                    return false;
                });

        $("#btnAdd")
                .live("click", function () {
                    // duplicate a row and force unique element id's
                    var table = $("#participants_list");
                    var tr = table.find('tr:first').next().clone()
                    $(tr).find('input').each(function () {
                        if (this.type === "text") { $(this).val(''); } // clear text
                    });
                    $(tr).appendTo(table);

                    refineIndexes();
                });

        function refineIndexes() {
            // function to duplicate a row and update unique element id's
            var index = 0;
            $("#participants_list").find('tr').next().each(function () {
                $(this).find('input').each(function () {

                    var newId = this.id.replace(parseInt(this.id.match(/[\d\.]+/g)[0], null).toString(), index);
                    var newName = this.name.replace(parseInt(this.name.match(/[\d\.]+/g)[0], null).toString(), index);

                    // IE7 struggling with 'name' attribute
                    if ($.browser.msie && $.browser.version.substr(0, 1) <= 7) {
                        // for readability
                        var oldInput = $(this);

                        // recreate new input and add to DOM
                        var newInput = $("<input type=\"" + this.type + "\" id=\"" + newId + "\" name=\"" + newName + "\" />").addClass(oldInput.attr("class")).val(oldInput.val()).insertAfter(oldInput);

                        // set checked attribute on radio
                        // remove old input from DOM
                        oldInput.remove();

                    } else {
                        $(this).attr({ id: newId, name: newName });
                    }
                });

                $(this).find('.num').text(function () {
                    var elSpan = $(this).text();
                    var nr = parseInt(elSpan.match(/[\d\.]+/g)[0], null);
                    return elSpan.replace(nr.toString(), index + 1);
                });

                $(this).find('label').attr('for', function () {
                    elFor = $(this).attr('for');
                    var nr = parseInt(elFor.match(/[\d\.]+/g)[0], null);
                    return elFor.replace(nr.toString(), index);
                });
                index++;
            });


        }



    });
});
Java Afca
  • 2,217
  • 4
  • 16
  • 10
  • 1
    You need to be a little bit polite, if you want to get answers her. Either accept the only answer you've got or write a comment, why you don't accept it, please. – trejder Jun 06 '14 at 04:31

1 Answers1

2

look at the queue process in the documentation.

Methods like 'loaded' can be used to calculate the total uploaded and then subtracted from the total of the directory size which the user is uploading to. (Directory_size - uploaded_size = total_available)

Then if the total_available is a negative value then you know to reject it.

Sunny Patel
  • 535
  • 2
  • 5
  • 13