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

前端 未结 13 1405
隐瞒了意图╮
隐瞒了意图╮ 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:55

    Why do not you just use CSS to disable the click event. When max files is reached, Dropzone will automatically add a class of dz-max-files-reached.

    Use css to disable click on dropzone:

    .dz-max-files-reached {
              pointer-events: none;
              cursor: default;
    }
    

    Credit: this answer

提交回复
热议问题