<div class="form-group">
<label for="exampleInputFile">文章封面</label>
<input name="cover" type="file" onchange="fileChange(this)" id="file">
<div class="thumbnail-waper">
<img class="img-thumbnail" src="" id="preview">
</div>
</div>
var file = document.getElementById("file");
var preview = document.getElementById("preview");
function fileChange() {
var reader = new FileReader();
reader.readAsDataURL(this.files[0]);
reader.onload = function() {
console.log(reader.result);
preview.src = reader.result;
}
}