话不多说,上代码
//file为input的id
$('#file').change(function(){
var fil = this.files[0];
reads(fil);
})
function reads(fil){
var reader = new FileReader();
reader.readAsDataURL(fil);
reader.onload = function(){
document.getElementById("preview").innerHTML='';
document.getElementById("preview").innerHTML += "![]("+reader.result+")";
};
}