layout:'column',
fieldLabel:'商品图片',
name:'productPicture',
fileUpload : false,
items:[{
xtype:"textfield",
inputType:"file",
allowBlank:false,
blankText:'请上传图片'
怎么获取我上传文件的路径呢??
[quote]layout:'column',
fieldLabel:'商品图片',
name:'productPicture',
fileUpload : false,
items:[{
xtype:"textfield",
inputType:"file",
allowBlank:false,
blankText:'请上传图片'
怎么获取我上传文件的路径呢?? [/quote]
如果你想在浏览器中获取文件上传的路径,建议你放弃,使用ie的话是可以获得,使用ie以为的浏览器你是只能获得文件名的.而且在前端js获得这些信息的意义不是太大.
var uploadForm= new Ext.FormPanel({
id: 'form-panel',
fileUpload: true,
width: 500,
frame: true,
collapsible:true,
autoHeight: true,
bodyStyle: 'padding: 10px 10px 0 10px;',
labelWidth: 50,
defaults: {
anchor: '95%',
allowBlank: false,
msgTarget: 'side'
},
items: [{
xtype:'combo',
width : 200,
allowBlank : false,
blankText : '必须选择文档类型',
hiddenName : 'CId', //这个hiddenName指的就是BookTypeId
name : 'CName',
store : new Ext.data.Store({
autoLoad :true,
reader: new Ext.data.JsonReader({//读取json数据
root:'TCategoryList', //
totalProperty:'totalProperty', //总记录数
id:'CId'
},
Ext.data.Record.create([
{name: 'CId'},
{name: 'CName'}
])
),
proxy : new Ext.data.HttpProxy({
url : path+'doc/getTCategoryForDoc.action'
})
}),//设置数据源
allQuery:'alldoc',//查询全部信息的查询字符串
triggerAction: 'all',//单击触发按钮显示全部数据
editable : false,//禁止编辑
loadingText : '正在加载文档类型信息',//加载数据时显示的提示信息
displayField:'CName',//定义要显示的字段
valueField : 'CId',
emptyText :'请选择文档类型',
mode: 'remote',//远程模式
id:'CName',
fieldLabel:'类型'
},{
xtype: 'fileuploadfield',
id: 'form-file',
emptyText: '请选择流程文件...',
fieldLabel: '文件',
name: 'upload', // ★ from字段,对应后台java的bean属性,上传的文件字段
buttonCfg: {
text: '', // 上传文件时的本地查找按钮
iconCls: 'icon-upload' // 按钮上的图片,定义在CSS中
}
},
{
xtype: 'hidden',
id: 'fileName',
emptyText: '请选择文档文件...',
name: 'fileName',
text:Ext.getCmp("form-file") //在上传这个框中,getCmp可以获取整条路径的最后的名称
},
{
xtype:'hidden',
name : 'docId',
id:'docId'
}
],
buttons: [{
text: '上传',
handler: function(){
if(uploadForm.getForm().isValid()){
uploadForm.getForm().submit({
url:path+ 'upload/upload.action?Tab_staffId='+staffId,
method:'POST',
waitTitle: '请稍后',
waitMsg: '正在上传文档文件 ...',
success: function(fp, action){
msg('成功!', '文档文件上传成功!');
//msg("返回的ID呢"+action.result.docId);
//Ext.log('上传成功。')
//Ext.log(action.failure)
//failure
//Ext.log(action.result.upload);
//Ext.log(action.result.msg);
Ext.getCmp("form-file").reset(); // 指定文件字段的id清空其内容
Ext.getCmp("CName").reset();
},
failure: function(fp, action){
msg('失败!', '文档文件上传失败!');
}
});
}
}
},{
text: '重置',
handler: function(){
uploadForm.getForm().reset();
}
}]
});
后台接收两个字段属性java.io.File的File和String 的fileName