日期:2014-05-16  浏览次数:20313 次

ExtJs 图片上传
上传控件:   
var panel3 = new Ext.form.FormPanel({   
    labelAlign : 'left',   
         labelWidth:60,   
    border : false,   
    bodyStyle : 'padding:4px;',   
    frame : false,   
    url : '../ajaxdata/uploadFile.jsp',   
    autoHeight : true,   
    fileUpload : true,   
    items : [{   
        id : 'file',   
        autoScroll : false,   
        xtype : 'textfield'  
                  fieldLabel:'本地上传',   
        name : 'file',   
        hideLabel : true,   
        // inputType : 'file'//按照Ext默认的属性将inputType设为file时,始终响应不了onchange事件,结果就以autoCreate的方式,如下,因为这种方式相当于html里的input,所以也就响应得了啦!   
  
        autoCreate : {   
            tag : "input",   
            type : "file",   
            size : "20",   
            autocomplete : "off",   
            onChange : "browseImages(this.value);"  
        }   
    }]   
  
    ,   
    buttons : [{   
        text : '上传',   
        handler : function() {   
            panel3.getForm().submit({   
                // waitTitle : "请稍候",   
                waitMsg : "正在上传...",   
                success : function(form, action){},   
                failure : function(form, action) {   
                    Global.alert('上传图片失败!');   
                }   
            })   
        }   
    }]   
});   
  
/*   
* 编辑  
* @date 2008 July 10  
*/  
经过实践,还存在一种可以激发change事件的方法;   
首先说一下获取form里面的field的三种方法:   
1)Ext.getCmp('id');