admin管理员组

文章数量:1203388

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?

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?

Share Improve this question edited Oct 14, 2016 at 17:18 Jean-François Gagnon 1702 silver badges12 bronze badges asked Mar 20, 2015 at 6:53 AVMAVM 3031 gold badge4 silver badges15 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 22

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); 
    });

本文标签: javascriptDropzone max file size exceeded eventStack Overflow