1.js预览图片:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<script type="text/javascript">
function changepic() {
//document.getElementById("#prompt3").css("display", "none");
var reads = new FileReader();
var f = document.getElementById('chosefile').files[0];
reads.readAsDataURL(f);
reads.onload = function(event) {
document.getElementById('showimg').src = this.result;
// document.getElementById("#img3").css("display", "block");
};
}
</script>
<body>
<div>
<!--当vaule值改变时执行changepic函数,规定上传的文件只能是图片-->
<input type="file" id="chosefile" style="width: 200px;height: 30px;" onchange="changepic()" accept="image/jpg,image/jpeg,image/png,image/PNG"><br>
<img src="" id="showimg" style="width: 300px;height: 300px;" />
</div>
</body>
</html>
<%@ page contentType="text/h