zoukankan      html  css  js  c++  java
  • 图片上传验证

     {
            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('文件格式不正确');
                }
                
                
        },

  • 相关阅读:
    玩转VIM编辑器额外技巧
    玩转VIM编辑器自动补全
    玩转VIM编辑器vim附加特性
    Silverlight 4 Tools中文版下载
    Silverlight4 入门GetStart
    Silverlight SNS项目
    Silverlight VS2010下的RIA开发活动整站
    Silverlight4(Visual Studio 2010下的RIA开发)技术交流会圆满结束
    SYSTECH的界面设计器
    实现自定义Silverlight的安装界面
  • 原文地址:https://www.cnblogs.com/tian114527375/p/5790592.html
Copyright © 2011-2022 走看看