参考:
【前端解决方案】input file 上传图片,并实现实时预览_fileinput 动态加载预览数据-CSDN博客
<div class="am-form-group am-form-file"> <div class="tpl-form-file-img"> <img id="backimg" src="/static/admin/assets/img/code.png" class="am-img-responsive" alt=""> </div> <input id="doc-form-file" type="file" multiple="" onchange="reads(this)"> </div>
function reads(obj) { var file = obj.files[0]; var reader = new FileReader(); reader.readAsDataURL(file); reader.onload = function (ev) { $("#backimg").attr("src", ev.target.result); } }
标签:function,前端,点击,file,reader,var,ev,图片 From: https://www.cnblogs.com/hmy22466/p/18125077