的缩略图
在提交表单上传之前,如何从蓝色插件中选定的文件列表中删除文件。我尝试了所以答案,但是它只是从ui中删除了不是从队列中删除文件。
这是我的代码
$(function(){
$("#UploadPhotos").click(function(){
$("#ItemPhotos").click();
});
$('#ItemPhotos').fileupload({
url: "${pageContext.servletContext.contextPath}/XYZ",
//dataType: 'json',
autoUpload: false,
acceptFileTypes: /(.|/)(gif|jpe?g|png)$/i,
maxFileSize: 5000000, // 5 MB
// Enable image resizing, except for Android and Opera,
// which actually support image resizing, but fail to
// send Blob objects via XHR requests:
disableImageResize: /Android(?!.*Chrome)|Opera/
.test(window.navigator.userAgent),
previewMaxWidth: 171,
singleFileUploads:false,
previewMaxHeight: 180,
previewCrop: true
}).on('fileuploadadd', function (e, data) {
data.context = $('<div/>').appendTo('#FilesListThumb');
$.each(data.files, function (index, file) {
var node = $('<div><h6>X</h6></div>').addClass("thumbnail-ib");
node.appendTo(data.context);
node.find("h6").click(function(){
node.remove();
});
});
$("#itemSellForm").submit(function(){
data.formData = $("#itemSellForm").serializeArray();
data.submit();
return false;
});
}).on('fileuploadprocessalways', function (e, data) {
var index = data.index,
file = data.files[index],
node = $(data.context.children()[index]);
if (file.preview) {
node
.addClass("thumbnail")
.append(file.preview);
}
if (file.error) {
node
.addClass("thumbnail")
.append($('<span class="text-danger"/>').text("Upload Failed"));
}
}).on('fileuploadfail', function (e, data) {
$.each(data.files, function (index, file) {
var error = $('<span class="text-danger"/>').text('File upload failed.');
$(data.context.children()[index])
.append('<br>')
.append(error);
});
}).on("fileuploaddone",function(e,data){
// sendData = false;
alert("done");
});
});
当我单击H6缩略图时,从ui中删除了ifles
每个blueimp回调都有2个参数: event
和 data
对象。
data
对象包含一个files
数组,您可以编辑该数组,以更改将要上传的文件。因此,如果在提交请求之前删除这些数组元素之一(array.pop
或其他方法...),则可以将其视为删除。。
也许有助于另外单击" uploadphotos" delete/unbind的事件。
$("#UploadPhotos").unbind("click")