I need to change maxFiles option programmatically. This is my init:
Dropzone.options.dropzone = {
paramName: "files",
params:true,
url: "/upload.php",
autoProcessQueue: true,
uploadMultiple: true,
parallelUploads: 10,
maxFiles: fileleft,
previewsContainer: ".dropzone",
clickable: true,
addRemoveLinks: false,
acceptedFiles: '.jpg,.pdf,.png,.bmp',
dictInvalidFileType: 'Unsupported.',
accept: function(file, done) {
done();
},
init: function() {
var myDropzone = this;
this.on("successmultiple", function(files, response) {
ins.pop_gallery(id);
this.removeAllFiles();
this.on("maxfilesexceeded", function(file){
this.removeFile(file);
});
this.on("sending", function(file, xhr, formData) {
formData.append("custom", id );
});
}
}
Everything is working correctly, but I need to change the maxFiles option value later.
I've tried this:
Dropzone.options.dropzone.maxFiles = fileleft;
and this:
myDropzone.maxFiles = fileleft;
but despite this code
alert(Dropzone.options.dropzone.maxFiles);
give me the correct answer, the maxFiles upload limit in fact is still unchanged.
Any thought?
Thanks.
First of all, thank you for replaying. I have found some problem to reinitialize the plugin, at the end I think my error was in the init:
init: function() {
var myDropzone = this;
redeclaring the var I was loosing the visibility in the further code.
So changing in
init: function() {
myDropzone = this;
(without var)
myDropzone became accessible so the statement
myDropzone.options.maxFiles = fileleft;
now is working.
Thanks a lot.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With