Skip to content

when i use displayExistingFile function maxFiles does not seem to work #2031

Description

@tubbynl

Describe the bug
when i use displayExistingFile to init the Dropzone widget with files already uploaded it does not seem to handle the maxFiles setting correctly.

To Reproduce

  • set maxFiles to 10
  • add 8 files displayExistingFile function
  • upload 4 files
  • all 4 files are accepted by the widget
  • if no files are added using displayExistingFile and i upload 12 files it works (gives errors on the last 2 files)
Dropzone.options.productPhotoDropzone = {
            maxFiles: 10,
            init: function () {
                let thisDropzone = this;
                $.getJSON("/some/endpoint/producing/json/list/with/8/items", function (data) {
                    $.each(data, function (index, productImage) {
                        thisDropzone.displayExistingFile(productImage, productImage.dataURL);
                    });
                });
                thisDropzone.on('success', function (file,productImage) {
                    if(!thisDropzone.getQueuedFiles().length) {
                        location.reload();
                    }
                });
                thisDropzone.on('error', function (file) {
                    if(!thisDropzone.getQueuedFiles().length) {
                        location.reload();
                    }
                });
            }
        };

Expected behavior

  • i expect errors for maxFiles reached

Browser / OS:

  • OS & Device: MacOS on a MacBook Pro
  • Browser FireFox
  • Version 91.0.2 (64-bits)

Screenshots

scenario one; having 8 images loaded via displayExistingFile and uploading 4 (expect 2 to be rejected)
Schermafbeelding 2021-09-09 om 20 12 39
scenario two; having 0 images loaded via displayExistingFile and uploading 12 (2 are rejected )
Schermafbeelding 2021-09-09 om 20 13 03

Additional context

produced json response by /some/endpoint/producing/json/list/with/8/items uri

[
  {
    "type": "image/jpeg",
    "kind": "image",
    "accepted": true,
    "name": "image-from-ios-613a4a3583170969636064.jpg",
    "dataURL": "assets/product/63178/image-from-ios-613a4a3583170969636064.jpg",
    "size": 363732
  },
  ... 6 more items in this array ...
  {
    "type": "image/jpeg",
    "kind": "image",
    "accepted": true,
    "name": "image-from-ios-2-613a4a3782aea724275026.jpg",
    "dataURL": "assets/product/63178/image-from-ios-2-613a4a3782aea724275026.jpg",
    "size": 331934
  }
]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions