Delete files programmatically with jquery fileupload basic

前端 未结 3 1804
攒了一身酷
攒了一身酷 2021-02-05 10:11

I\'m using the blueimp file upload plugin (the basic version) to implement multifile upload. I am trying to implement functionality to allow the user to remove queued files for

3条回答
  •  梦如初夏
    2021-02-05 10:26

    Thanks for that @Furynation.

    What I did was similar to your approach. For every file I select I add a row to a table(pre upload submission). This row I assign to the data.context to use for later use.

    See: https://github.com/blueimp/jQuery-File-Upload/issues/3083

    My code snippet is in the add callback handler:

     $("#upload").click(function () {
                     if (data.files.length > 0) { 
                         data.submit();
                     }
                });
                data.context.find('a').on('click',function (event) {  
                    event.preventDefault();
                    data.context.remove();   
                    data.files.length = 0;   
                });
    

    This removes the table row and resets the array.

    If there is a cleaner way, please let me know.

提交回复
热议问题