2008-07-24
struts1.2 + Ext2.0实现多文件上传
上传界面代码
form代码
action代码AddGameAction.java
但是这样MS只是适合小的文件上传,没试过太大的文件
另外向高手们讨教个问题:ext占用客户端的资源越来越多有什么解决办法?
var gameFrom = new Ext.form.FormPanel({
width:300,
height:400,
fileUpload:true,
frame:true,
bodyStyle: 'padding:5px 5px 0',
labelAlign:'center',
items:[
new Ext.form.TextField({fieldLabel:'游戏截图1',name:'picture1',inputType:'file',allowBlank:false}),
new Ext.form.TextField({fieldLabel:'游戏截图2',name:'picture2',inputType:'file'}),
new Ext.form.TextField({fieldLabel:'游戏截图3',name:'picture3',inputType:'file'})
//这里的名字picture1,picture2,picture3和form里面的对应,使用jsp的时候名字和form对应也能传上去
//相信生成的JS代码也是像<input type="file" name="picture1"/>这样的吧
//fileUpload:true == enctype="multipart/form-data" 这句吧
],
buttons:[
{text:'添加',handler:function(){
if(game_form.form.isValid()){
game_form.form.submit({
method:'POST',
url:'../admin/addGame.do',
waitMsg:'游戏添加中...',
success:function(){Ext.MessageBox.alert('添加信息','添加成功');},
failure:function(){Ext.MessageBox.alert('添加信息','添加失败');}
});
}else{
Ext.MessageBox.alert('提示', '请完整填写表单');
return;
}
add_dlg.hide();
}},
{text:'取消',handler:function(){
add_dlg.hide();
}
}
]
});
var addGame_dlg = new Ext.Window({
title:'添加游戏截图',
layout:'fit',
height:540,
width:650,
autoDestroy : true,
closeAction:'hide',
modal:true,
items:[gameFrom]
});
form代码
private FormFile picture1; private FormFile picture2; private FormFile picture3; 省略了get和set方法......
action代码AddGameAction.java
try {
FormFile picture1 = gameInfoForm.getPicture1();
gameInfo.setPictureMain(org.hibernate.Hibernate.createBlob(picture1
.getInputStream()));
FormFile picture2 = gameInfoForm.getPicture2();
gameInfo.setPicture1(org.hibernate.Hibernate.createBlob(picture2
.getInputStream()));
FormFile picture3 = gameInfoForm.getPicture3();
gameInfo.setPicture2(org.hibernate.Hibernate.createBlob(picture3
.getInputStream()));
} catch (Exception e) {
e.printStackTrace();
}
下面就是调用save等方法,保存当前的数据
将文件直接存入数据库中了.......
但是这样MS只是适合小的文件上传,没试过太大的文件
另外向高手们讨教个问题:ext占用客户端的资源越来越多有什么解决办法?
发表评论
提醒: 该博客已发表在公共论坛,博客所有留言会成为论坛回贴,留言请注意遵守论坛发贴规则
- 浏览: 3093 次
- 性别:

- 来自: 天津

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
各位,帮看看简历,在北京 ...
我和LZ差不多。很多地方比LZ差。不过也在北京找到了工作。。只是工资很低。。
-- by cc0128 -
各位,帮看看简历,在北京 ...
grave 写道差不多也就一普通毕业生简历,不过写的比较诚恳。这样的简历在北京能 ...
-- by 不是流氓 -
各位,帮看看简历,在北京 ...
差不多也就一普通毕业生简历,不过写的比较诚恳。
-- by grave -
hibernate查找重复列,并 ...
对啊,我开始也是查distinct,我日,那个不总是搞不定,就 group by ...
-- by 不是流氓 -
hibernate查找重复列,并 ...
果然是用group by,lz应该写清楚用了什么方法。
-- by spiritfrog






评论排行榜