简体   繁体   中英

I want to set dynamic max file upload in dropzone.js

HTML

<script src="./assets/js/dropzone.js"></script>
<input type="text" id="maxFileUpload" value="5"/>

dropzone.js

(function() {
.
.
Dropzone.prototype.defaultOptions = {
      maxFiles: $("#maxFileUpload").val(),

can't get value. But value the undefined. I try document.getElementById('maxFileUpload').value It doesn't work.

Do not know what to do?

try updating the dz object on change (assuming the user can change)

(function() {

    var dz = new Dropzone({
        //init
    });

    $("#maxFileUpload").change(function(){
        dz.options.maxFiles = parseInt($(this).val());
    })

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM