zoukankan      html  css  js  c++  java
  • jq html 页面点击图片直接上传

    <form id="ff" method="post" enctype="multipart/form-data" style="padding-top: 23px;">
      <input style="display: none" name="custId" id="custId"/>
      <font style="margin: 25px 0 0 10px;color: #5c5c5c;">头像</font>
      <img src="${contextPath}/static/images/btn_next.png" style="float: right;padding-right: 15px;height: 20px;"></img>
      <div style="height: 50px;float: right;margin-top: -13px;">
        <div onclick="changeImg()">
          <img src="" style="height:50px;float: left;margin-right:25px;" id="facePath" name="facePath" >
        </div>
        <input id="img_path" style="display: none" name="userLogo" type="file" accept="image/*" />
      </div>
      <div style="display: none;" onclick="addPath()" id="dd">确定</div>
    </form>

    //上传图片
    /* function changeImg(){
      $("#img_path").trigger('click');
    }
    $("#img_path").change(function(){
      var file = this.files[0] ? this.files[0] : null;
      if (!file) { return false; }
      var file_reader = new FileReader();
      file_reader.onload = (function(){
        var image_url = this.result; // 这是图片的路径
        $('#facePath').attr('src', '');
        $('#facePath').attr('src', image_url); // 创建图片标签
      });
      file_reader.readAsDataURL(file);

      $("#dd").trigger('click');

    });
    function addPath(){
      var userLogo = $("#img_path").val();//图片地址
      var custId = $("#custId").val();
      if(userLogo != null && custId != null){
        $.ajax({
          cache: true,
          type: "POST",
          url: "${contextPath}/my/page/changeinfo_userface",
          data: $("#ff").serialize(),
          async: false,
          success: function(data){
            if(data != null){
            var jsonData = eval("("+data+")");
            var message = jsonData.message;
            var status = jsonData.status;
            if(status == "OK"){
              wxAlert(message);
            }else{
              wxAlert(message);
              return;
            }

           }
          }

        });
      }
    } */

  • 相关阅读:
    windows phone中三种解析XML的方法
    windows phone因为墓碑化导致“正在恢复”的分析
    windows phone之获取当前连接WIFI的SSID
    在wp中,使用NavigationService.Navigate导航页面出现错误
    数据结构之单链表,c#实现
    数据结构之顺序表,c#实现
    优化C#程序的48种方法
    一次js代码修改不更新问题的解决
    Java与Unicode
    JAVA中线程同步的方法
  • 原文地址:https://www.cnblogs.com/sho560/p/5630265.html
Copyright © 2011-2022 走看看