1. 程式人生 > >uploadify附件上傳 傳參

uploadify附件上傳 傳參

show mda message rev AC events div pre typeid

首先 在剛加載jsp時就加入上傳方法,所以 formDate 中的參數 zFileName是頁面剛加載時 exp1的值 ,後來通過js方法賦值不被讀過來,
如果 你想要獲得這個值,可在 調用uploadify之前先把參數加入,見 save 方法


$(document).ready(function() {
$(‘#edit_file_upload‘).uploadify({
auto:false,
buttonClass: "some-class",
buttonCursor: ‘hand‘,
height: 20,
width: 90,
buttonText: ‘<div>選擇文件</div>‘,
fileSizeLimit : ‘102400KB‘,
fileObjName: ‘myfile‘,
fileTypeExts: ‘*.*‘,
multi: true,
preventCaching: true,
queueID : ‘edit_file_upload-queue‘,
progressData: ‘percentage‘,
overrideEvents : [‘onSelectError‘],
formData: {‘typeId‘:‘1‘, ‘typeName‘:‘2‘,‘zFileName‘:$("#exp1").val(),‘id‘:‘${tEdasFlowApprove.id}‘,‘fileId‘:$("#fileId").val()},
swf:‘${ctxStatic}/uploadify/uploadify.swf‘,
uploader:‘${ctx}/flow/approve/tEdasFlowApprove/addFile;JSESSIONID=<shiro:principal property="sessionid"/>‘,
onFallback : function() {//檢測FLASH失敗調用
alert("您未安裝FLASH控件,無法上傳圖片!請安裝FLASH控件後再試。");
},
onSelectError : uploadify_onSelectError,
onUploadSuccess : function(file, data, response) {
$(‘#‘ + file.id).find(‘.data‘).html(‘上傳完畢‘);
data = eval(‘(‘+data+‘)‘);
fileId = data.fileId + ",";
var old_val = $(‘#fileId‘).val();
$(‘#fileId‘).val(old_val + fileId);
},
onQueueComplete : function(queueData) {
var fileId = $("#fileId").val();
if((fileId!=(""))&&(fileId.substring(fileId.length-1)==(","))){
$("#fileId").val(fileId.substring(0, fileId.length-1));
}
$("#inputForm").submit();

},
onUploadError : function(file, errorCode, errorMsg, errorString) {
$.messager.show({
title:‘我的消息‘,
msg: errorString,
timeout:5000,
showType:‘slide‘
});
}
});


});


function save(){
  $("#edit_file_upload").uploadify("settings", "formData", {‘zFileName‘:$("input[name=exp1]").val()});
  $(‘#edit_file_upload‘).uploadify(‘upload‘,‘*‘);
}


jsp
<input type="file" name="edit_file_upload" id="edit_file_upload" multiple="multiple"  />
<div id ="edit_file_upload-queue"></div>
<div id="edit_form_upload"></div>

uploadify附件上傳 傳參