我正在使用bluimp文件上传:所有它的工作正常但如果我在函数中添加这行代码,进度条从每个文件的零重新开始...我不会进展所有吧!如果我删除该代码(用于图像大小调整),进度条可以正常工作。
disableImageResize: /Android(?!.*Chrome)|Opera/
.test(window.navigator && navigator.userAgent),
imageMaxWidth: 2126,
imageMaxHeight: 2126,
loadImageMaxFileSize: 20000000,
这是我的全部功能:
$(function () {
var count = 0;
var qt = 1;
$('#fileupload').fileupload({
dropZone: '',
dataType: 'json',
disableImageResize: /Android(?!.*Chrome)|Opera/
.test(window.navigator && navigator.userAgent),
imageMaxWidth: 2126,
imageMaxHeight: 2126,
loadImageMaxFileSize: 20000000,
formData: [{ name: 'custom_dir', value: <?php echo $_SESSION['folder']; ?>+'/singleprint/' }],
done: function (e, data) {
c = Math.floor((Math.random() * 1000000) + 1);
$.each(data.result.files, function (index, file) {
$('<div class="sp-item"><div class="sp-image-preview"><a data-lightbox="uploadedfiles" data-title="'+file.name+'" href="uploads/<?php echo $_SESSION['folder']; ?>/singleprint/'+file.name+'"><img alt="'+file.name+'" id="original-image'+c+'" style="cursor: pointer;" src="uploads/<?php echo $_SESSION['folder']; ?>/singleprint/thumbnail/'+file.name+'"></a></div><div class="sp-image-options"><span class="image-name">'+file.name+'</span><br />Quantità <select class="singleImageQt" name="qt-'+qt+'" onchange="updateQt();"><?php for($o=1;$o<11;$o++){echo '<option value="'.$o.'">'.$o.'</option>';}?></select><input type="hidden" name="filename-'+qt+'" value="'+file.name+'"></div></div>').appendTo("#image-grid");
count=count + 120;
qt = qt + 1;
});
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$("#percentage").html(progress);
if(progress != 0){
$('#progress .uploadbar').css(
'height',
'10px'
);
$('#container-box').css(
'opacity',
'0.05'
);
$('#progress').css(
'opacity',
'1'
);
}
$('#progress .uploadbar').css(
'width',
progress + '%'
);
if(progress == 100){
$("#sp-quantity").html("<p>"+qt+"</p>");
$("#general-qt").html("<span>"+qt+"</span>");
$('#nimmagini').val(qt);
$('#progress .uploadbar').css(
'height',
'0px'
);
$('#image-grid').css({
"opacity":"1","z-index":"1"
});
$('#image-grid-container').css(
'height',
count+'px'
);
$('#progress').css(
'opacity',
'0'
);
$('#container-box').css(
'opacity',
'0'
);
}
}
});
});