Uploading multiple files with the same file.name using dropzone.js

前端 未结 4 562
Happy的楠姐
Happy的楠姐 2020-12-18 17:13

I\'m implementing dropzone.js and everything is perfect until I try to upload multiple files with the same name, let\'s say uploading photos from an iOS device where all hav

4条回答
  •  悲哀的现实
    2020-12-18 18:01

    This is a very simple way to do it based off hien's answer. This example also users the jQuery plugin.

    When a file is added, have the server echo back name of the file on the server. Capture this with the dropzone success event, appending the server file name as a new property on the file object. Then you can access the property on the dropzone removedfile event, and send it back to the server as the name of the file to be deleted.

    this.on("success", function (file, serverFileName) {
        file.serverFileName = serverFileName;
    });
    this.on("removedfile", function (file) {
        $.post("process.php?deleteFile=" + encodeURIComponent(file.serverFileName));
    });
    

提交回复
热议问题