Ext 文件上传 fileuploadfield 帮帮忙 急呀

fixed 2011-04-06 03:12:01
帮帮忙 给我写出后台的代码吧 给提示也行 我不知道后台怎么接收
我要保存 文件名 和文件路径 当然文件也是肯定要保存的。帮帮忙
前台代码我已经写好了



Ext.onReady(function(){

Ext.QuickTips.init();

var msg = function(title, msg){
Ext.Msg.show({
title: title,
msg: msg,
minWidth: 200,
modal: true,
icon: Ext.Msg.INFO,
buttons: Ext.Msg.OK
});
};

var fp = new Ext.FormPanel({
renderTo: 'fi-form',
fileUpload: true,
width: 500,
frame: true,
title: 'File Upload Form',
autoHeight: true,
bodyStyle: 'padding: 10px 10px 0 10px;',
labelWidth: 50,
defaults: {
anchor: '95%',
msgTarget: 'side'
},
items: [{
xtype: 'textfield',
fieldLabel: 'Name',
name:"common.name",
id:"fileName"
},{
xtype: 'fileuploadfield',
id: 'formFile',
emptyText: 'Select an image',
fieldLabel: 'Photo',
name: 'common.fileStr',
fileUpload : true,
buttonText: '',
buttonCfg: {
iconCls: 'upload-icon'
}
}],
buttons: [{
text: 'Save',
handler: function(){
var v = Ext.getCmp('formFile').getValue();
alert(v);
if(fp.getForm().isValid()){
fp.getForm().submit({
url: "/common/common_fileLoad.action",
method:'POST',
waitMsg: 'Uploading your photo...',
success: function(fp, o){
msg('Success', 'Processed file "'+o.result.file+'" on the server');
}
});
}
}
},{
text: 'Reset',
handler: function(){
fp.getForm().getEl().dom.reset();
}
}]
});

});

...全文
1191 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
ghl0903 2013-01-16
  • 打赏
  • 举报
回复
请问大侠,按着你说的方法,可以取到上传文件的名称了,控件把文件保存到什么位置了呢,还有如果想自己保存该文件,怎么获取上传文件的全路径呢。或者有什么好方法
fixed 2012-06-18
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 的回复:]

用fileuploadfield上传文件,如果想取消刚刚选中的文件怎么办
[/Quote]

这个不知道
号是我的了 2012-06-05
  • 打赏
  • 举报
回复
用fileuploadfield上传文件,如果想取消刚刚选中的文件怎么办
tianya_zhichi 2011-06-21
  • 打赏
  • 举报
回复
在submit中加入 params : {id : rec.get("id"),
date : frm.findField("date").getValue()}
在后台用String id = resquest.getParameter("id");得到后台传过来的id,
fixed 2011-04-06
  • 打赏
  • 举报
回复
自己写一下 省的别人也不知道

xtype: 'fileuploadfield',
id: 'formFile',
emptyText: 'Select an image',
fieldLabel: 'Photo',
name: 'common.fileStr',
fileUpload : true,
buttonText: '',
buttonCfg: {
iconCls: 'upload-icon'
}

文件名和 文件类型很好获得
如果用的是 struts2 只要在 对象bean 中 怎家两个属性
比如 在 common 中 增加 fileStrType fileStrFileName

两个属性 Ext.fileuploadfield 组件 就会自动赋值。而 fileStr就是 Java.Io.File 对象 至于怎么应用大家都知道的。

886
fixed 2011-04-06
  • 打赏
  • 举报
回复
我 已经解决 虽然没哟 很好的答案 不过结贴了
清晨v 2011-04-06
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 fixed_2008 的回复:]

大哥 给点提示吧 后台接收的是 什么类型
怎么获取 文件名
[/Quote]
BASE64吧,将文件转换成base64提交,实际上就是传输的字符串了,再在后台将这个字符串转成文件,至于文件名你传两个参数不就行了!
fixed 2011-04-06
  • 打赏
  • 举报
回复
大哥 给点提示吧 后台接收的是 什么类型
怎么获取 文件名
fixed 2011-04-06
  • 打赏
  • 举报
回复
struts2 用的自动赋值 试了 File 对象 可是
File f = common.getFileStr();
System.out.println(f.getPath());
却打印
“C:\Users\YZ\.IntelliJIdea10\system\tomcat\Unnamed_jd-pmpab5310fe\work\Catalina\localhost\_\upload_4e67f0dc_12f2994f625__8000_00000011.tmp”
对吗?
fixed 2011-04-06
  • 打赏
  • 举报
回复
java
Mr-Jee 2011-04-06
  • 打赏
  • 举报
回复
你后台什么语言
fixed 2011-04-06
  • 打赏
  • 举报
回复
谢谢我看了 可是这个跟后台取数据没关系呀。。。
我现在是根本就不知道后台怎么办?用什么接收。怎么 保存文件
Mr-Jee 2011-04-06
  • 打赏
  • 举报
回复
http://ext.group.iteye.com/group/blog/738366

我觉得应该看下文档~
fixed 2011-04-06
  • 打赏
  • 举报
回复
各位帮帮 忙就 是复制个 代码也行啊。。我真的 一点办法都没有了
fixed 2011-04-06
  • 打赏
  • 举报
回复
自己顶个先 帮帮忙了 ================================================================

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧