AVM AVM - 1 month ago 16
HTML Question

Dropzone max file size exceeded event

I am using dropzone in my form for image upload. I would like to show an alert message and remove the file added when the user chooses a file above the configured limit.
Here is my configuration:

Dropzone.options.myDropzone = {
paramName: 'file',
url: "http://someurl",
clickable: true,
enqueueForUpload: true,
autoProcessQueue: false,
uploadMultiple: true,
parallelUploads: 5,
maxFiles: 1,
maxFilesize: .06,
maxThumbnailFilesize: .06,
acceptedMimeTypes: 'image/*',
addRemoveLinks: true,
dictDefaultMessage: 'Drag your images here',
init: function() {
console.log('init');
this.on("maxfilesexceeded", function(file){
alert("No more files please!");
this.removeFile(file);
});

}
};


I tried to register a listener for 'maxfilesizeexceeded' event, but it didnt fire.
I would like to take similar action as for 'maxfilesexceeded'.
Is this possible?

Answer

I have just tried it out on my script using the Error event. This way I get an Error Message and the File gets removed again. Is this what you are looking for?

    this.on("error", function(file, message) { 
                alert(message);
                this.removeFile(file); 
    });