Cho đến nay, việc triển khai tải lên của tôi đang chạy khá trơn tru ngoại trừ một vấn đề dai dẳng.Tải lên + Giao diện người dùng jQuery
Tôi có lời nhắc duyệt qua tải lên trong cửa sổ hộp thoại jquery-ui. Các tệp được tải lên tốt nhưng đối với mỗi mục tệp được chọn, hai mục hàng giống hệt nhau (cùng một id) xuất hiện.
Chỉ một trong các mục hàng đợi này thực sự được cập nhật với thanh tiến trình mặc dù cả hai dường như đều nhận được cập nhật phần trăm.
Khi tệp tải lên hoàn tất, chỉ một trong các mục hàng đợi này (cùng một mục được cập nhật với thanh tiến trình) bị xóa.
Tôi đã thử nghiệm nó bên ngoài cửa sổ modal thoại jquery-ui và hàng đợi đôi hành vi mục biến mất.
Tôi muốn giữ lời nhắc tải lên và xếp hàng trong cửa sổ hộp thoại phương thức nếu có thể.
Bất kỳ manh mối nào về lý do tại sao việc sử dụng uploadify trong cửa sổ phương thức jquery-ui làm cho hành vi mục hàng gấp đôi này?
UPDATE:
$("#Filedata").uploadify({
'scriptAccess': 'allways',
'uploader' :'<?php echo base_url();?>js/jquery.uploadify-v2.1.4/uploadify.allglyphs.swf',
'script': '<?php echo site_url();?>/upload/process_upload',
'cancelImg': '<?php echo base_url();?>js/jquery.uploadify-v2.1.4/cancel.png',
'folder' : '/',
'fileDataName' :'Filedata',
'buttonText' : 'Document...',
'width': '273',
'height': '51',
'wmode': 'transparent',
'auto' : true,
'multi' : false,
'fileExt' : '*.pdf;', 'fileDesc' :'Document',
'sizeLimit' : 10485760,
'simUploadLimit' : 1,
'queueSizeLimit' :'1',
'uploaderType' : 'flash',
'scriptData' : {'userdata':'<?php echo $userdata;?>','upload_token':'<?php echo $token['value'];?>'},
onProgress: function() {
//hide upload button
$("object#FiledataUploader").height(0);
},
//workaround for bug in jQuery UI dialog/upoadify (double progress bars)
onOpen : function(event,ID,fileObj) {
$('#FiledataQueue div.uploadifyQueueItem:first-child').hide();
},
onError: function(a, b, c, d) {
if (d.status == 404)
alert('Could not find upload script. Use a path relative to: ' + '<?= getcwd() ?>');
else if (d.type === "HTTP")
alert('error ' + d.type + ": " + d.info);
else if (d.type === "File Size")
alert(c.name + ' ' + d.type + ' Limit: ' + Math.round(d.sizeLimit/1024) + 'KB');
else
alert('error ' + d.type + ": " + d.info);
},
onComplete : function (event, queueID, fileObj, response, data) {
var r = JSON.parse(response);
$('#token').val(r['token']);
$('#uploaded_filename').val(r['uploaded_filename']);
$('#filename_encryption').val(r['encryption']);
$('#FiledataQueue').html('Document <span class="bold" style="font-weight:bold;">'+ r['filename'] + '</span>');
},
onQueueFull: function(event, queueSizeLimit) {
// supress dialog that mentions the queue is full
return false;
}
});
HTML:
<form id="form-document" method="" action="">
<input type="file" name="Filedata" id="Filedata" size="20" />
<input type="hidden" name="response" id="response" value=""/>
<input type="hidden" name="upload_token" id="upload_token" value=""/>
<input type="hidden" name="uploaded_filename" id="uploaded_filename" value=""/>
<input type="hidden" name="filename_encryption" id="filename_encription" value=""/>
<input type="hidden" name="uploaded_extension" id="uploaded_extension" value=""/>
<input type="hidden" name="token" id="token" value="<?php echo $token['value'];?>"/>
</form>
UPDATE 2:
jQuery UI thoại:
dialog_data.dialog({
autoOpen: false,
height: 700,
width: 800,
modal: true,
bigframe: true,
buttons: {
'Save': function() {
$.ajax({
type: "GET",
url: "<?php echo site_url();?>/upload/finish",
dataType: 'html',
data: $('#form-document').serialize(),
success: function(){
oCache.iCacheLower = -1;
oTable.fnDraw();
dialog_data.dialog('close');
}
});
},
'Close': function() {
$(this).dialog('close');
$('.loading').hide();
}
},
open: function(){
$('.loading').hide();
$("object#FiledataUploader").height(30);
},
close: function() {
$('#uploaded_filename').val('');
$('#filename_encription').val('');
$('#FiledataQueue').html('');
}
});
Tôi giải quyết nó với giải pháp workaround nhưng tôi không hài lòng với cách giải quyết. Tôi muốn biết thêm thông tin về lỗi này (có thể). – mojeime
mã của bạn, vui lòng? – ifaour
Bạn nên chia sẻ cách giải quyết của mình trong trường hợp bất kỳ ai khác gặp sự cố. – Jimmy