• 获取本地地址,获取上传文件的后缀


     // 获取地址
                
    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]));
                }
            }); 
    

      

  • 相关阅读:
    AGC 015 E
    CF 1041 F. Ray in the tube
    AGC 005 D
    CF 348 D. Turtles
    2069: [POI2004]ZAW
    AGC 007 D
    zhengruioi 470 区间
    2653: middle
    Django 源码安装及使用
    Django MTV模型思想
  • 原文地址:https://www.cnblogs.com/lhy-93/p/5741545.html
Copyright © 2020-2023  润新知