//ext代码
var _fileForm = new Ext.FormPanel({
layout : "fit",
frame : true,
border : false,
autoHeight : true,
waitMsgTarget : true,
defaults : {
bodyStyle : 'padding:10px'
},
margins : '0 0 0 0',
labelAlign : "left",
labelWidth : 50,
fileUpload : true,
items : [{
xtype : 'fieldset',
title : '选择文件',
autoHeight : true,
items : [{
id : 'uploadFileId',
name : 'uploadFile',
xtype : "textfield",
fieldLabel : '文件',
inputType : 'file',
anchor : '96%'
}]
}]
});
//action代码
private File uploadFile;// 上传文件域对象 ,该名称一定要与上传文件类型的name一致,struts2自动会通过setter进行注入
// 上传文件名
private String uploadFileFileName; //在上传文件name+FileName就是上传文件名称,struts2自动注入
// 上传文件类型
private String uploadFileContentType;public File getUploadFile() {
return uploadFile;
}
public void setUploadFile(File uploadFile) {
this.uploadFile = uploadFile;
}
public String getUploadFileFileName() {
return uploadFileFileName;
}
public void setUploadFileFileName(String uploadFileFileName) {
this.uploadFileFileName = uploadFileFileName;
}
public String getUploadFileContentType() {
return uploadFileContentType;
}
public void setUploadFileContentType(String uploadFileContentType) {
this.uploadFileContentType = uploadFileContentType;
}