dropzone upload only one file

前端 未结 6 1307
时光说笑
时光说笑 2021-02-01 02:11

I am using dropzone.js for my drag-drop file upload solution. I want to upload only one file,if i upload second file the first one should be remove and second one should be uplo

6条回答
  •  面向向阳花
    2021-02-01 02:55

    maxFiles: 1 is used to tell dropzone that there should be only one file. When there is more than 1 file the function maxfilesexceeded will be called, with the exceeding file as the first parameter.

    here is a simple function to delete preview of first file and add the new one :)

    maxFiles:1,
    init: function() {
          this.on("maxfilesexceeded", function(file) {
                this.removeAllFiles();
                this.addFile(file);
          });
    }   
    

提交回复
热议问题