您的位置:首页 > Web前端 > JavaScript

ExtJs文件上传

2017-01-19 10:05 253 查看
var form = new Ext.form.FormPanel
({
layout:'form',
labelWidth:60,
labelAlign:'right',
fileUpload:true,/////////////////
items:
[{
id:'file',
xtype:'textfield',
fileUpload:true,  
fieldLabel:'项目资料',
labelStyle:'margin:0 0 10px 0;',
name: 'uploadFile',   
inputType: 'file',
blankText: '请上传文件',
width:170,

}]
});

//新增项目

var addProgram = new Ext.Window

({
title:'项目申报',
layout:'form',
autoHeight:true,
width:350,
frame:true,
//closeAction:'hide',
labelWidth:60,
modal:true,
labelAlign:'right',
items:[form],
buttons:
[{
text:'申报',
handler:function()
{
form.getForm().submit

({  

           url:pm_papplication_add,
           method:'POST',   
           success:function(resp,obt)
           {  
           
               Ext.MessageBox.alert("提示信息","申报成功!");  
           },  
           failure : function(form, action) 
           {  
               Ext.MessageBox.alert("提示信息","申报失败!");  
           }  
       }); 
}
},
{
text:'取消',
handler:function()
{
addProgram.close();
}
}],
buttonAlign:'center'

}).show();

//获取上传文件
public void add(HttpSession session,HttpServletRequest request,HttpServletResponse response,
@RequestParam(value="uploadFile")MultipartFile multipartFile)
{

//存取路径

        String path = session.getServletContext().getRealPath("upload/resource/");

//通过MultipartFile存取到服务器中
       
multipartFile.transferTo(new File(path,multipartFile.getOriginalFilename()));

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  文件上传