0

I create a file uploader with Dropzone.js

<div id="dropzone"></div>

and jquery code:

$("#dropzone").dropzone({
    url: '/',
    multiple:false,
    autoProcessQueue: false,
    paramName: "file",
    addRemoveLinks: true,
    dictRemoveFile: '<span class="fa fa-close"></span>',
    acceptedFiles: 'image/jpeg',
});

But when I render page I can select multiple image. I want users just select one image and when they again select other imageT second image replace with first image.

  • Possible duplicate: https://stackoverflow.com/questions/18048825/how-to-limit-the-number-of-dropzone-js-files-uploaded – Rory McCrossan Jan 21 '20 at 09:13
  • @RoryMcCrossan In your link image preview show but cant upload, I want don't show more than one image –  Jan 21 '20 at 09:16

1 Answers1

0

Edit your jquery code:

$("#dropzone").dropzone({
    url: '/',
    multiple:false,
    autoProcessQueue: false,
    paramName: "file",
    addRemoveLinks: true,
    dictRemoveFile: '<span class="fa fa-close"></span>',
    acceptedFiles: 'image/jpeg',
    init: function() {
      this.on("addedfile", function() {
        if (this.files[1]!=null){
          this.removeFile(this.files[0]);
        }
      });
    }
});