我正在使用 Blueimp fileupload 在我的项目中上传图片。加载图像后,我想为每个图像放置一个按钮,可以在上传之前按下该按钮以将其从上传队列中清除(如插件演示页面中的那个@ http://blueimp.github.io /jQuery-文件上传/)。我到处寻找我似乎无法找到真正适合我的解决方案......这是我一直在使用的代码......
$('#fileupload').fileupload({
dataType: 'json',
autoUpload: false,
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
disableImageResize: /Android(?!.*Chrome)|Opera/
.test(window.navigator.userAgent),
imageMaxWidth: 1000,
imageMaxHeight: 800,
previewMaxWidth: 100,
previewMaxHeight: 100,
previewCrop: false
}).on('fileuploadadd', function (e, data) {
//Add buttons for canceling individual images
$("#uploadBttn").click(function () {
data.submit();
});
}).on('fileuploadprocessalways', function (e, data) {
var index = data.index,
file = data.files[index];
if (file.preview) {
$("#imgPreview").append(file.preview);
}
}).on('fileuploadprogressall', function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .bar').css('width',progress + '%');
}).on('fileuploadstart', function (e) {
$("#uploadBttn").unbind().prop('disabled', true).text('Uploading...');
}).on('fileuploadstop', function (e) {
$("#uploadBttn").text('Done!');
});