图片上传验证

 {
        colspan : 6,
        120,
        xtype: 'filefield',
        name: 'photo',
        120,
        buttonText: '选择文件',
        buttonOnly : true,    
        
        validator:function(value){
                            
                            var array=value.split('.');
                            if(array[array.length-1]=='jpg' || array[array.length-1]=='JPG'||array[array.length-1]=='bmp'){
                                if(this.fileInputEl.dom.files[0].size>20971){
                
                        
                
                                    return '文件不能超过20k';
                                }
                                                return true;
                                
                            }else{
                            
                                
                                
                                return '文件格式不正确';
                            }
                        
                        
                        },
            listeners:{
                        
                         change:{fn:'changeImgSrc'}
                        
             }                    
},

    changeImgSrc:function(me,o,e){
        
            var array=o.split('.');
            
            console.log(me.fileInputEl.dom.files[0]);
            if(array[array.length-1]=='jpg' || array[array.length-1]=='JPG'||array[array.length-1]=='bmp'){
                if(me.fileInputEl.dom.files[0].size>50971){
                
                        
                    console.log(this);
                    alert('文件不能超过50k');
                    this.lookupReference("filefileld").setValue("");
                    
                }else{
                
                
                    this.lookupReference('imageHead').getEl().dom.src=window.URL.createObjectURL(me.fileInputEl.dom.files[0]);
                    
                    this.lookupReference('imageHead').show();
                
                }
                            
                                
                                
            }else{
                            
                                
                    alert('文件格式不正确');
            }
            
            
    },