zoukankan      html  css  js  c++  java
  • 超简单的asp.net不用服务器控件File文件选中了后显示在img标签中

    首先创建一个页面

    关键代码如下:

    <div class="form-group">
      <label>头像:</label>
        <a href="javascript:;" class="file">
           <i class="layui-icon">�</i>
           <input type="file" id="upfile">选择图片
        </a>
      <img class="layui-upload-img" id="img_box" src="~/Imgs/@student.HeadImg" />
    </div>

     js代码如下:

    <script src="~/Scripts/jquery-3.4.1.js"></script>
    <script> var imgfFile //图片名称 $("#upfile").change(function () { imgfFile = $("#upfile").prop("files")[0];//prop添加属性名称 console.log(imgfFile.name) $("#img_box").attr('src', '/Imgs/' + imgfFile.name) })   </script>
  • 相关阅读:
    ⑨.tomcat性能优化
    ⑧.tomcat安全优化
    Nginx.HSTS
    https证书auto
    ⑦.tomcat 常见故障
    ⑨mvstat
    ⑥.tomcat监控
    ⑥.tomcat多实例
    ⑤.tomcat的三种工作模式
    ④.tomcat配置文件server.xml
  • 原文地址:https://www.cnblogs.com/thyandscc/p/12582919.html
Copyright © 2011-2022 走看看