Multiplefile upload using uplodify
I want to upload multiple files with title and links. And the code is :
$(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 c开发者_StackOverflow中文版ancelled.','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();
}
This code works file in IE but in firefox not working. In firefox the following script is not called
'script': 'admin/home-banner-list.aspx?process=fileupload'
could you try the following:
window.setTimeout("window.location.href='/admin/home-banner-list.aspx'",2000);
I have just added a '/' before 'admin'
Now its working... I have change the code as follows :
$('.txttitle').each(function(index) { 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() + '\''; });
'onAllComplete' do not called when 'multi'=>true.
精彩评论