首先 在刚加载jsp时就加入上传方法,所以 formDate 中的参数 zFileName是页面刚加载时 exp1的值 ,后来通过js方法赋值不被读过来,
如果 你想要获得这个值,可在 调用uploadify之前先把参数加入,见 save 方法
$(document).ready(function() {
$('#edit_file_upload').uploadify({
auto:false,
buttonClass: "some-class",
buttonCursor: 'hand',
height: 20,
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>