我想上传多个带标题和链接的文件。代码是:
$(document).ready(function()
{
$('#divUpload').uploadify(
{
'uploader': 'admin/fileupload/uploadify.swf',
'script': 'admin/home-banner-list.aspx?process=fileupload',
'multi' : 'true',
'method' : 'POST',
'cancelImg' :'admin/images/cancel.png',
'folder': '../source/BannerImage',
'queueSizeLimit' : '20',
'fileDesc' : '*.JPEG;*.JPG;*.GIF;*.PNG;*.BMP',
'fileExt': '*.JPEG;*.JPG;*.GIF;*.PNG;*.BMP',
'wmode' : 'transparent',
'onCancel':function(event,queueID,fileObj,data)
{
if(data['fileCount']==0)
{
txtboxIndex=0;
$('#btnUploadfile').hide();
$('#btnCancelUploadfile').hide();
}
else
{
txtboxIndex=txtboxIndex-1;
}
},
'onAllComplete': function(event,data)
{
jQuery('#'+divMsg).css('display','');
jQuery('#'+divMsg).html('Banner(s) has been uploaded successfully.').attr('class','successmsg');
window.setTimeout("window.location.href='admin/home-banner-list.aspx'",2000);
},
'onSelect' : function(event,queueid,fileObj)
{
$('#btnUploadfile').show();
$('#btnCancelUploadfile').show();
},
'onComplete': function(event,queueID,fileObj,response,data)
{
if(response=='maxupload')errcnt++;
}
})
});
function CancelUpload()
{
$('#divUpload').uploadifyClearQueue();
if(jQuery('.uploadifyQueueItem').length>0)
DisplMsg('<%= divMsg.ClientID %>','Banner(s) upload has been cancelled.','msgerror');
window.setTimeout("window.location.href='admin/home-banner-list.aspx'",2000);
}
function UploadFiles()
{
var cnt='';
var str='';
$('.tbxLink').each(function(index)
{
if(jQuery.trim($(this).val())!='')
{
if(!isValidURL(jQuery.trim($(this).val())))
{
if(cnt.length ==0)
cnt=(index + 1);
else
cnt=cnt + ',' +(index + 1);
}
}
});
if(cnt.length!=0)
{
alert('Please insert valid link in image#' + cnt);
return false;
}
$('.txttitle').each(function(index)
{
cnt= $(this).attr('name').replace('txttitle','');
str =str + ',\'' + $(this).attr('name') + '\':\'' + $(this).val() + '\'';
str =str + ',\'' + 'tbxLink' + cnt + '\':\'' + $('#tbxLink' + cnt).val() + '\'';
str= str + ',\'' + cnt + '\':\'' + $('#hdnfile'+ cnt).val() + '\'';
});
str = str.substring(1);
str='{' + str + '}';
$('#divUpload').uploadifySettings('scriptData', str ,false);
$('#divUpload').uploadifyUpload();
}
此代码在IE中工作,但在Firefox中无法正常工作。 在firefox中,不会调用以下脚本
'script':'admin / home-banner-list.aspx?process = fileupload'
答案 0 :(得分:0)
你可以尝试以下方法:
window.setTimeout( “window.location.href = '/管理/家庭横幅list.aspx'”,2000);
我刚在'admin'之前添加了'/'
答案 1 :(得分:0)
现在它的工作...... 我更改了代码如下:
$( 'txttitle')。每个(函数(指数) { cnt = $(this).attr('name')。replace('txttitle',''); str = str +',\''+ $(this).attr('name')+'\':\''+ $(this).val()+'\''; str = str +',\''+ $('#tbxLink'+ cnt).attr('name')+'\':\''+ $('#tbxLink'+ cnt).val( )+'\''; str = str +',\''+ cnt +'\':\''+ $('#hdnfile'+ cnt).val()+'\''; });
答案 2 :(得分:0)
'onAllComplete' do not called when 'multi'=>true.