jQuery-File-Upload cancel uploading by javascript

2019-07-15 19:38发布

I am using jQuery-File-Upload https://github.com/blueimp/jQuery-File-Upload and i want to implement cancel uploading on click of cancel button manually, i know there is a callback "fileuploadfail" but can anyone give example how we use it.

1条回答
Summer. ? 凉城
2楼-- · 2019-07-15 20:09

Implement Cancel event using below code

var jqXHR = $('#fileupload').fileupload('send', {files: filesList})
    .error(function (jqXHR, textStatus, errorThrown) {
        if (errorThrown === 'abort') {
            alert('File Upload has been canceled');
        }
    });
$('button.cancel').click(function (e) {
    jqXHR.abort();
});
查看更多
登录 后发表回答