zoukankan      html  css  js  c++  java
  • 获取本地地址,获取上传文件的后缀

     // 获取地址
                
    function getObjectURL(file) {
             var url = null ;
             if (window.createObjectURL!=undefined) { // basic
             url = window.createObjectURL(file) ;
             } else if (window.URL!=undefined) { // mozilla(firefox)
             url = window.URL.createObjectURL(file) ;
             } else if (window.webkitURL!=undefined) { // webkit or chrome
             url = window.webkitURL.createObjectURL(file) ;
             }
             return url ;
       }
    

      

     
    //获取上传文件的后缀
    $("#bgInputFile").on("change", function () {
                var filepath = $("input[name='bgInputFile']").val();
                var extStart = filepath.lastIndexOf(".");
                var ext = filepath.substring(extStart,filepath.length).toUpperCase();
                if(ext!=".JPG"){
                    alert("图片限于jpg格式");
                }else {
                    // $("#imgFile").show();
                    // $("#imgFile").attr('src',getObjectURL($("#bgInputFile")[0].files[0]));
                }
            }); 
    

      

  • 相关阅读:
    逻辑回归
    异常
    内部类
    接口
    多态
    final关键字(最终的)
    不能被继承的父类成员
    对象初始化的过程
    方法重写
    abstract关键字
  • 原文地址:https://www.cnblogs.com/lhy-93/p/5741545.html
Copyright © 2011-2022 走看看