Cannot remove files from file list using JQuery-File-Upload

前端 未结 5 1608
鱼传尺愫
鱼传尺愫 2020-12-20 17:59

I have an issue using the JQuery-File-Upload plugin. I am using the plugin directly and not through the author\'s provided html example pages. Basically I have a form with s

5条回答
  •  無奈伤痛
    2020-12-20 18:46

    I had the same problem and the only way I've managed to solve that was to check in the submit callback if the file was already uploaded. I just check if the file name is included in the array fileNames which I push the current file name before the submission and checks on the next time if the next one is present on the array and if so cancel the submission.

    var fileNames = new Array();
    
    $('#uploadfile').fileupload({
      submit: function(e, data) ->
        var fileName = data.files[0].name;
        if ($.inArray(fileName, fileNames) === -1)
          fileNames.push(fileName);
        else
          return false;
    });
    

提交回复
热议问题