For this kind of problem handling;
js code:
function getSessionId(){ var c_name = 'JSESSIONID'; if(document.cookie.length>0){ c_start=document.cookie.indexOf(c_name + "=") if(c_start!=-1){ c_start=c_start + c_name.length+1 c_end=document.cookie.indexOf(";",c_start) if(c_end==-1) c_end=document.cookie.length return unescape(document.cookie.substring(c_start,c_end)); } } }
The uploadify method in the jquery.uploadify.js file:
Modify the red marked part of the
uploader 'uploader': '/incms/upload2/init.json ;jsessionid='+getSessionId()
The uploader instance code is as follows:
$('#uploadXls').uploadify({ 'swf' : SWF, 'buttonText' : 'Browse', 'width' : 50, 'height' : 20, 'fileSizeLimit' : '60MB', 'multi' : true, 'car': false, 'successTimeout': 900,//The maximum timeout time returned by the server/second 'method' : 'POST', 'queueSizeLimit' : 100, 'fileTypeDesc' : 'Upload Files', 'fileTypeExts' : '*.xls; *.xlsx', 'formData' : {'fileAmount':''},//'netType':'', 'uploadLimit' :15, 'uploader' : '/incms/upload2/init.json;jsessionid='+getSessionId(), 'onDialogClose': function(queueData){ fileAmount = queueData.filesQueued; }, 'onDialogOpen':function (){ $('#uploadXls').uploadify('cancel','*'); }, 'onUploadStart' : function(file) { $.messager.progress({title:'Please waiting',msg:'Importing.....',text:''}); }, 'onSelect': function (file) { if(!$("#uploadIsMac").val()){ $('#uploadXls').uploadify('cancel','*'); $('#upload_detail_dialog').dialog('close'); $.messager.alert(titleInfo,"Please select a device"); return; } }, 'onCancel': function (file) { fileAmount=fileAmount-1; }, 'onUploadSuccess' : function(file, data, response) { //alert("PP:"+response); if(response==false){ $.messager.progress('close'); $.messager.alert(titleInfo, 'The data is too large, please check if all the imports are successful!'); $('#uploadXls').uploadify('cancel','*'); $('#upload_detail_table').datagrid('load'); $('#upload_detail_dialog').dialog('close'); }else{ var json = $ .parseJSON (data); var jsonData=json.data.msg;//Return information if(jsonData !=null && jsonData !=''){ if (json.data.code == 3) { //The selected manufacturer has no data $.messager.progress('close'); $('#uploadXls').uploadify('cancel','*'); $('#upload_detail_table').datagrid('load'); $('#upload_detail_dialog').dialog('close'); $.messager.alert(titleInfo, json.data.msg); }else if(json.data.code==2){ //Partial import succeeded $.messager.progress('close'); $.messager.alert(titleInfo,json.data.offerMsg); $('#uploadXls').uploadify('cancel','*'); $('#upload_detail_table').datagrid('load'); $('#upload_detail_dialog').dialog('close'); } }else{ // do not display 100% of the progress $.messager.progress({title:'Please waiting',msg:'Importing.....',text:''}); } } }, 'onAllComplete' : function(event,data) { }, 'onUploadError' : function(file, errorCode, errorMsg, errorString) { } });