extjs3.2+struts1.2文件上传问题。。急。。谢谢大家了。
ext form表单部分代码:
var addDoc = new Ext.FormPanel({
id: 'docType1',
anchor: '90%',
fieldLabel: '附件类型',
name: 'docType1',
xtype: 'combo',
bodyStyle: 'padding:10px;',
valueField: "value",
emptyText: '请选择附件类型',
blankText: '请输入附件类型',
displayField: "text",
allowBlank: false,
store:new Ext.data.SimpleStore({
fields: ["value", "text"],
data: [['1','Word主题'],['xls','Excel主题'],['jpg','JPG图片'],['jpeg','JPEG图片'],['gif','GIF图片'],['bmp','BMP图片'],['7','视频图像']]
}),
mode: 'local'
},{
fieldLabel: '*上传附件(2M)',
id: 'file-file',
name: 'file',
itmesCls: 'float-left',
clearCls: 'allow-foat',
//fileUpload : true, // 指定表单将要进行文件上传
anchor: '90%',
xtype: 'textfield',
inputType: 'file',//输入类型
listeners:{
blur:function(){
var file_upl = document.getElementById('file-file');
file_upl.select();
var filePath = document.selection.createRange().text; //获取上传文件路劲
if(filePath!=""){
var path_name=filePath.substr(filePath.lastIndexOf("\\")+1,filePath.length-1);//获取上传文件名
var fileType=filePath.substr(filePath.lastIndexOf(".")+1,filePath.length-1);//获取上传文件类型
var doc_type= Ext.getCmp("docType1").getValue(); //获取上传文件类型
if(doc_type==1){
if(fileType.toLowerCase() !="doc" && fileType.toLowerCase()!="docx"){
Ext.Msg.alert("提示信息"," 上传文件格式不正确");
return;
}
}
if(doc_type!=1 && doc_type!=7){
if(fileType.toLowerCase() !=doc_type){
Ext.Msg.alert("提示信息"," 上传文件格式不正确");
return;
}
//未验证视频格式
}
Ext.getCmp("docType").setValue(doc_type); //模板文件类型赋值
Ext.getCmp("file").setValue(filePath); //模板文件类型赋值
}
}
}
},{
xtype: 'label',
fieldLabel: '模板文件',
id: 'accessory1',
anchor: '90%',
name: 'accessory1',
allowBlank: false
}, {
xtype: 'radiogroup',
fieldLabel: '公开/私密',
anchor: '60%',
name: 'rbauto',
items: [
{boxLabel: '公开', name: 'rbauto', inputValue: 1},
{boxLabel: '私密', name: 'rbauto', inputValue: 0, checked: true}
]
}],
buttons: [{
text: '保存',
handler:function(){
if(addDoc.form.isValid()){
Ext.MessageBox.show({
title: '提示',
msg: '正在保存...',
progressText: '',
width: 300,
progress: true,
closable: false,
animEl: 'loding'
});
var f = function(v){
return function(){
var i = v/11;
Ext.MessageBox.updateProgress(i, '');
};
};
for(var i = 1; i < 13; i++){
setTimeout(f(i), i*150);
}
addDoc.form.doAction('submit',{
url:'docSendManager.do?method=saveAndUpdateDoc',
method:'post',
success:function(form,action){
if (action.result.msg=='ok') {
addDoc.form.reset();
addDocWindow.hide();
Ext.MessageBox.hide();
Ext.Msg.alert('操作提示',"保存成功");
reloadTreeAndGrid();
} else {
Ext.Msg.alert('操作提示',action.result.msg);
}
},
failure:function(){
Ext.Msg.alert('操作提示','服务器错误,请稍后再试...');
}
});
}
}
},{
text: '重置',
handler:function(){addDoc.form.reset();}
}
]
});
actionfrom部分代码:
/**
* 稿件模板附件引用相对路径
*
* @hibernate.property
*/
private FormFile file;
private String expireTime;//截止时间
private String description;// 主题描述
private String rbauto;//公开/私密状态
private String person; //用户
public FormFile getFile() {
return file;
}
public void setFile(FormFile file) {
this.file = file;
}
public String getPerson() {
return person;
}
public void setPerson(String person) {
action部分代码
public ActionForward saveAndUpdateDoc(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
response.setContentType("text/html");
// 设置字符编码为UTF-8, 这样支持汉字显示
response.setCharacterEncoding("UTF-8");
FileManagerForm fileManager = (FileManagerForm) form;
FormFile pfile = fileManager.getFile();//获取文件路径
String docName=fileManager.getTheme();//主题名
String endTime=fileManager.getExpireTime();// 截止日期
String dec=fileManager.getDescription();//描述
String doctype=fileManager.getDocType();//附件类型
String accessory=fileManager.getAccessory();//附件名称
int rbauto=Integer.parseInt(fileManager.getRbauto());//公开/私密
int person=Integer.parseInt(fileManager.getPerson());// 用户ID
System.out.println("文件路径:"+pfile);
System.out.println("主题名:"+docName);
System.out.println("截止日期:"+endTime);
System.out.println("描述:"+dec);
System.out.println("附件类型:"+doctype);
System.out.println("附件名称:"+accessory);
System.out.println("公开/私密"+rbauto);
System.out.println("用户ID"+person);
打印结果::
文件路径:null
附件类型:1
附件名称:四川电大毕业设计.doc
公开/私密0
用户ID2026
请问。。为什么file为null呀??
我换成File接收也是null、。、
网上查说将:fileUpload : true
但是这样也不行。。。
在aip中,也没有找到fileUpload 属性
还有的说将:xtype:'uploadPanel'
同样,,在3.2的api中也xtype没有发现有这个属性。
请问应该怎么样,才能