zoukankan      html  css  js  c++  java
  • 移动端头像上传

    头像上传HTML代码:

    <form  action="/index.php?m=&c=User&a=uploadImage" method="post" id="formid" enctype= "multipart/form-data" style="display: block;">
            <input id="upfiles" class="upfiles" type="file" name="log" onchange="uploadOperate();">
            <a class="pic-img">
                <img class="showimg" width="100px" onclick="" src="">
            </a>
            <input type="submit" value="提交" class="btn2">
    </form>
    

    上传之后显示当前头像:

       $("#upfiles").change(function(){
            var objUrl = getObjectURL(this.files[0]) ;
            if (objUrl) {
                $(".showimg").attr("src", objUrl);
            }
        })
    
        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;
        }
    

      

  • 相关阅读:
    centos部署bladex boot 之docker安装
    git ssh key创建和github使用
    Debian root登录设置
    Linux软件源
    Secure backup
    Python简易web服务
    好久没有更新博客了
    Python实现无向图最短路径
    DWZ使用中遇到的坑
    tronado学习
  • 原文地址:https://www.cnblogs.com/share123/p/5478496.html
Copyright © 2011-2022 走看看