PixelPaul
PixelPaul

Reputation: 2777

Don't allow additional added images to be added after maximum is reached (dropzonejs)

I'm working on some modifications to the dropzonejs image uploader. I want to allow a maximum of 12 image uploads. I see the config for maxFiles, but after setting this to 12 it still allows files to be added and generates thumbnail previews. Is there are way to modify, so once the limit of 12 is reached it will no longer generate a thumbnail or add the files to the upload list?

Upvotes: 0

Views: 47

Answers (1)

wallek876
wallek876

Reputation: 3259

Use the dropzone maxfilesexceeded event, that triggers for every file rejected for exced the limit, to remove this files:

Dropzone.options.myDropzone = {
    maxFiles: 12,
    init: function() {
        this.on('maxfilesexceeded', function(file){
            this.removeFile(file);
        });
    }
};

Upvotes: 1

Related Questions