天天看点

input file隐藏以及 input file选中预览

<label>
    <div class="col-sm-8">
       <span><img alt="image" class="img-circle images" src="{$img}" width="128px"/></span>
       <input class="imgInput" name="image" type="file"  style="display:none;">
    </div>
</label>
           
加入style="display:none;"并用label包裹
加入预览js
$(".imgInput").change(function(){
  $(".images").attr("src",URL.createObjectURL($(this)[0].files[0]));
});