js文件上传图片展示
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>图片上传</title>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script>
function changepic() {
var reads = new FileReader();
f = $('#getImg')[0].files[0]
reads.readAsDataURL(f);
reads.onload = function (e) {
console.log(this.result)
document.getElementById('img3').src = this.result;
$("#img3").css("display", "block");
};
}
</script>
</head>
<body>
<input id="getImg" type="file" value="上传" onchange="changepic(this)">
<img src="#" id="img3" STYLE="display:none;width:120px;padding:5px;border: 1px solid #ddd;margin-top: 15px;"/>
</body>
</html>