How to limit the number of dropzone.js files uploaded?

前端 未结 13 1359
隐瞒了意图╮
隐瞒了意图╮ 2020-11-28 04:28

Depending on the use case, how do I constrain the number of files that dropzone.js will allow?

For example, I might need to only allow 1, 2, or 4 files uploaded.

13条回答
  •  温柔的废话
    2020-11-28 04:51

    You can also add in callbacks - here I'm using Dropzone for Angular

    dzCallbacks = {
        'addedfile' : function(file){
            $scope.btSend = false;
            $scope.form.logoFile = file;
        },
        'success' : function(file, xhr){
            $scope.btSend = true;
            console.log(file, xhr);
        },
        'maxfilesexceeded': function(file) {
             $timeout(function() { 
                file._removeLink.click();
            }, 2000);
        }
    }
    

提交回复
热议问题