zoukankan      html  css  js  c++  java
  • 单图上传预览

    //html部分
    <div class="">
        <label class="col-sm-2 control-label">活动图片</label>
        <div class="col-sm-9">
            <img  id="img0" style=" 100px;height: 100px" src=""><input type="file" name="file" id="file0" /><span style='color:red' id="span_flie0"></span>
        </div>
    </div>
    //JS部分
    <script>
        //jquery上传图片前预览
    $("#file0").change(function(){
            var objUrl = getObjectURL(this.files[0]) ;
            console.log("objUrl = "+objUrl) ;
            if (objUrl) {
                $("#img0").attr("src", objUrl) ;
            }
        }) ;
        //建立一個可存取到該fileurl
    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 ;
        }
    </script>
  • 相关阅读:
    hdu 1258 DFS
    hdu2488 dfs
    poj1915 BFS
    hdu1372 BFS求最短路径长度
    poj3264 线段树
    hdu 2438Turn the corner 三分
    hdu3714 三分
    【转载】单点登陆
    ajax从入门到深入精通
    Web前端技术体系大全搜索
  • 原文地址:https://www.cnblogs.com/zhangzhongran/p/6600852.html
Copyright © 2011-2022 走看看