EXTjs上传文件上传控件

 

 

View Code
 1 Ext.onReady(function(){
 2     var fileUpload = new Ext.FormPanel({ 
 3         id:'fileUpload',
 4         frame:true,
 5         fileUpload:true,
 6         items:[{
 7                     xtype:'textfield',
 8                     labelStyle : 'text-align:right;',
 9                     allowBlank:false,
10                     fieldLabel:'选择文件',
11                     inputType:'file',
12                     name:'fileName',
13                     width:200
14                 }
15           ],
16           buttonAlign:'center',
17           buttons:[{
18                   text:'上传',
19                 handler:function(){
20                         if(fileUpload.form.isValid()){
21                             fileUpload.form.submit({
22                                 method:'post',
23                                 url:'DefaultUrl',//根据自己系统的需要调用程序处理上传文件
24                                 waitMsg:'文件上传中...',
25                                 success: function() {
26                                     Ext.Msg.alert("系统提示", "文件上传成功!");
27                                 },
28                                 failure: function() {
29                                     Ext.Msg.alert("系统提示", "文件上传失败!");
30                                 }
31                             });
32                         }else{
33                             Ext.Msg.alert("系统提示","请选择文件后再上传!");
34                         }
35                     }
36                 },{
37                     text:'取消',
38                     handler:function(){
39                         winFielUpload.hide();
40                     }
41                 }
42          ]
43     });
44     var winFielUpload=new Ext.Window({
45         id:'win',
46         title:'文件上传',
47         //****renderTo:'divWindow',//对于window不要使用renderTo属性,只需要调用show方法就可以显示,添加此属性会难以控制其位置
48         width:350,
49         closeAction:'hide',//close缺省的动作是从DOM树中移除window并彻底加以销毁, hide隐藏
50         height:105,
51         layout:'fit',
52         autoDestory:true,
53         modal:true,
54         closeAction:'hide',
55         items:[
56             fileUpload
57         ]
58     }).show();
59 });

 

 

 

posted @ 2013-06-21 15:38  冬季小虫  阅读(659)  评论(0编辑  收藏  举报