到目前为止,我的uploadify实现运行相对平稳,除了一个唠叨的问题。Uploadify + jQuery UI
我有我的uploadify浏览提示在jquery-ui对话框模式窗口中。 文件上传正常,但对于每个选定的文件项目,会出现两个相同的队列项目(相同的ID)。
只有其中一个队列项实际上使用进度条更新,尽管两者似乎都获得了更新百分比。
文件上传完成后,只有其中一个队列项目(与进度栏一起更新的队列项目)被删除。
我测试了jQuery UI的对话模式窗口和双队列项行为消失之外。
我很想保持uploadify提示,如果可能的话,在模态对话窗口中排队。
任何线索为什么在jquery-ui模式窗口中使用uploadify导致这种双重队列项目行为?
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>
更新2:
jQuery用户界面对话框:
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('');
}
});
我解决了它解决方案的解决方案,但我不满意解决方法。我想知道更多关于这个(可能)错误的信息。 – mojeime 2011-01-18 23:13:47
你的代码好吗? – ifaour 2011-01-19 00:23:43