我正在使用Blueimp jQuery File Upload,它工作正常,但我在取消其中一个文件的上传时遇到了问题。
当我添加一个文件时,我将一个带有一些额外输入和一个按钮的字段集附加到 html 中 - “取消”。我需要的是这样的:
$(".cancelUpload").on("click", function(){
//remove this file from the queue, The data and the file will not be uploaded
})
这是我的代码的一部分
$('#MappeFile').fileupload({
dataType : 'json',
autoUpload : false,
maxNumberOfFiles : undefined,
maxFileSize : 2000,
minFileSize : undefined,
acceptFileTypes : /.+$/i,
url : "/ajax/UploadFile.php",
add : function(e, data) {
$("#fileUploadButton").removeClass("toHide").on("click", function() {
$('#progress .bar').show();
if ($.browser.msie && parseInt($.browser.version, 10) < 10) {
$('#progress .bar').css({
"background" : "url(images/progressbar.gif) no-repeat",
"width" : "100%"
})
} else {
$('#progress .bar').css({
'background-color' : "#2694E8",
'width' : '0%'
});
}
data.formData=$("form").serializeArray();
data.submit();
$("#fileUploadButton").off("click").addClass("toHide")
})
},
change : function(e, data) {
$.each(data.files, function(index, file) {
filesCount++;
vOutput = "<fieldset class='FileUploadFieldset'>"
vOutput += "<legend>" + file.name + "</legend>"
vOutput += "<label>Dateiname:</label><input type='text' value='"+file.name+"' name='Dateiname"+filesCount+"' size='50' class='UploadDateiName inputMaske'/><input type='text' class='toHide originName' name='originName"+filesCount+"' value='"+file.name+"'/>"
vOutput += "<label>Dokumentdatum</label><input type='text' name='Datum"+filesCount+"' class='UploadDatum inputMaske'>"
vOutput += "<label>Berater:</label><select name='Berater"+filesCount+"' class='UploadBeraterSelect inputMaske'></select>"
vOutput += "<fieldset><legend>Kategorie:</legend><div class='UploadKategorie'></div></fieldset>"
vOutput += "<fieldset><legend>Bemerkung:</legend><textarea name='Bemerkung"+filesCount+"' class='UploadBemerkung inputMaske'></textarea></fieldset>"
vOutput += "<input type='button' class='cancelUpload neuButton' value='cancel'/>"
vOutput += "</fieldset>"
$("#MappeFilesToUpload").append(vOutput);
});
}
});