需求改了,上传文件需要带参数,整了一上午,终于弄好:
<input type="file" name="file" id="fileName" size="27" />
$(document).ready(function(){
var ppth = path;
var gradeId=$("#importGradeSelect option:selected").val();
$('#fileName').uploadify({
'method':'GET', //如果要传参数,就必须改为GET
//这里只能传静态参数 'formData' : {'gradeId' : 1},
'swf':ppth+'js/uploadify.swf',
'auto':false,
'multi':false,
'queueSizeLimit':1,
'height':25,
'buttonText':'选择文件',
'uploader':ppth+'classesManager/importClasses.do',
'fileObjName':'file',
'fileTypeExts':'*.xls',
'itemTemplate' : '<div id="${fileID}" class="uploadify-queue-item">\<a href="javascript:delImport()" style="margin-right: 10px"><font color=red style="text-decoration: underline;">删除</font></a>\
<span class="fileName" title=${fileName}>${fileName} (${fileSize})</span><span class="data"></span>\
</div>',
"onUploadStart":function(file){//动态绑定参数对象
var gradeId=$("#importGradeSelect option:selected").val();
$("#fileName").uploadify('settings','formData', { 'gradeId': gradeId,'other': other});
},
'onUploadSuccess': function(file,data,response){
var jsonObj = $.parseJSON(data);
var success = jsonObj["success"];
if(success == true){
alert("导入成功。");
location.href = "../classesManager/queryClasses.do";
}else{
alert("导入失败,原因:" + jsonObj["message"]);
}
}
})
});
function startUpload(){
var index=$("#importGradeSelect").get(0).selectedIndex;
if(index !=0){
if(confirm("您确定要导入此组信息吗?")){
/*var gradeId=$("#importGradeSelect option:selected").val();
$('#fileName').uploadify('settings','formData', { 'gradeId': gradeId });
onUploadStart函数代替
*/
$('#fileName').uploadify('upload');
}
}else{
$("#importClassSelectMessage").html("<font color='red'>请选择年级!</font>");
}
}
<input type="file" name="file" id="fileName" size="27" />
$(document).ready(function(){
var ppth = path;
var gradeId=$("#importGradeSelect option:selected").val();
$('#fileName').uploadify({
'method':'GET', //如果要传参数,就必须改为GET
//这里只能传静态参数 'formData' : {'gradeId' : 1},
'swf':ppth+'js/uploadify.swf',
'auto':false,
'multi':false,
'queueSizeLimit':1,
'height':25,
'buttonText':'选择文件',
'uploader':ppth+'classesManager/importClasses.do',
'fileObjName':'file',
'fileTypeExts':'*.xls',
'itemTemplate' : '<div id="${fileID}" class="uploadify-queue-item">\<a href="javascript:delImport()" style="margin-right: 10px"><font color=red style="text-decoration: underline;">删除</font></a>\
<span class="fileName" title=${fileName}>${fileName} (${fileSize})</span><span class="data"></span>\
</div>',
"onUploadStart":function(file){//动态绑定参数对象
var gradeId=$("#importGradeSelect option:selected").val();
$("#fileName").uploadify('settings','formData', { 'gradeId': gradeId,'other': other});
},
'onUploadSuccess': function(file,data,response){
var jsonObj = $.parseJSON(data);
var success = jsonObj["success"];
if(success == true){
alert("导入成功。");
location.href = "../classesManager/queryClasses.do";
}else{
alert("导入失败,原因:" + jsonObj["message"]);
}
}
})
});
function startUpload(){
var index=$("#importGradeSelect").get(0).selectedIndex;
if(index !=0){
if(confirm("您确定要导入此组信息吗?")){
/*var gradeId=$("#importGradeSelect option:selected").val();
$('#fileName').uploadify('settings','formData', { 'gradeId': gradeId });
onUploadStart函数代替
*/
$('#fileName').uploadify('upload');
}
}else{
$("#importClassSelectMessage").html("<font color='red'>请选择年级!</font>");
}
}