头像点击预览代码
<style> #exampleInputFile { display: none; } </style>
<div class="form-group"> <label for="exampleInputFile">头像 <img src="/static/image/1552037426(1).jpg" id="header_image"> </label> <input type="file" id="exampleInputFile"> </div>
<script> $("#exampleInputFile").change(function () { var choose_file = $(this)[0].files[0]; var reader = new FileReader(); reader.readAsDataURL(choose_file); reader.onload = function () { $("#header_image").attr("src", reader.result) } }) </script>
Settle dowm and change