imgfrom.js
var f = new Ext.FormPanel({
id : 'f',
labelAlign : 'top',
frame : true,
modal : true,
url : path + 'upload/testUpload.action',
bodyStyle : 'padding:0 0 0',
width : 400,
imgfrom.js
var f = new Ext.FormPanel({
id : 'f',
labelAlign : 'top',
frame : true,
modal : true,
url : path + 'upload/testUpload.action',
bodyStyle : 'padding:0 0 0',
width : 400,
fileUpload : true,
items : [{
id : 'upload',
xtype : 'fileuploadfield',
fieldLabel : '商品图片上传',
textField : 'panel',
name : 'upload',
inputType : 'file'
}],
buttons : [{
text : '添加',
handler : function() {
if (f.getForm().isValid()) {
f.getForm().submit({
waitTitle : '请稍候',
waitMsg : '正在提交表单数据,请稍候...',
success : function(fr, actions) {
alert("dd");
alter(action.result.img);
Ext.getDom("_vipImg").src = path
+ "/images/userMobile"
+ action.result.img;
if (actions.result.success == true) {
Ext.MessageBox.alert("系统提示", "修改成功");
f.setVisible(false);
} else {
Ext.MessageBox.alert("系统提示", "连接超时");
}
}
})
}
}
}, {
text : '关闭',
handler : function() {
f.setVisible(false);
}
}]
});
var w = new Ext.Window({
id : 'addcW',
width : 300,
height : 200,
frame : true,
modal : true,
closeAction : 'hide',
title : '证件上传',
items : [f]
});
});
后台action
public String execute() throws Exception {
File[] srcFiles = this.getUpload();
List<String> successFileList=new ArrayList<String>();
// 处理每个要上传的文件
for (int i = 0; i < srcFiles.length; i++) {
// 根据服务器的文件保存地址和原文件名创建目录文件全路径
String dstPath = getRealyPath(getSavePath())
+ "\\" + this.getUploadFileName()[i];
File dstFile = new File(dstPath);
if(copy(srcFiles[i], dstFile)){
System.out.println(getUploadFileName()[i]);
successFileList.add(getUploadFileName()[i]);
}
}
getRequest().setAttribute("successFileList", successFileList);
commonality = "{success:true,img:"+getUploadFileName()[0]+"}";
return SUCCESS;
}
fileUpload : true,
items : [{
id : 'upload',
xtype : 'fileuploadfield',
fieldLabel : '商品图片上传',
textField : 'panel',
name : 'upload',
inputType : 'file'
}],
buttons : [{
text : '添加',
handler : function() {
if (f.getForm().isValid()) {
f.getForm().submit({
waitTitle : '请稍候',
waitMsg : '正在提交表单数据,请稍候...',
success : function(fr, actions) {
alert("dd");
alter(action.result.img);
Ext.getDom("_vipImg").src = path
+ "/images/userMobile"
+ action.result.img;
if (actions.result.success == true) {
Ext.MessageBox.alert("系统提示", "修改成功");
f.setVisible(false);
} else {
Ext.MessageBox.alert("系统提示", "连接超时");
}
}
})
}
}
}, {
text : '关闭',
handler : function() {
f.setVisible(false);
}
}]
});
var w = new Ext.Window({
id : 'addcW',
width : 300,
height : 200,
frame : true,
modal : true,
closeAction : 'hide',
title : '证件上传',
items : [f]
});
});
后台action
public String execute() throws Exception {
File[] srcFiles = this.getUpload();
List<String> successFileList=new ArrayList<String>();
// 处理每个要上传的文件
for (int i = 0; i < srcFiles.length; i++) {
// 根据服务器的文件保存地址和原文件名创建目录文件全路径
String dstPath = getRealyPath(getSavePath())
+ "\\" + this.getUploadFileName()[i];
File dstFile = new File(dstPath);
if(copy(srcFiles[i], dstFile)){
System.out.println(getUploadFileName()[i]);
successFileList.add(getUploadFileName()[i]);
}
}
getRequest().setAttribute("successFileList", successFileList);
commonality = "{success:true,img:"+getUploadFileName()[0]+"}";
return SUCCESS;
}
图片上传服务器没有问题.前台就是没有相应
success : function(fr, actions)
Ext success 没有相应
最新推荐文章于 2024-08-11 00:23:30 发布