感谢您的支持,我会继续努力的!
打开微信扫一扫,即可进行扫码打赏哦
点我查看本站打赏源码!
Powered by RUNCODEX.COM,学的不仅是技术,更是梦想!!!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>文档标题</title>
</head>
<body>
<div id="imgPreview">
<div id="prompt3">
<span id="imgSpan">
点击上传
<br />
<i class="aui-iconfont aui-icon-plus"></i>
<!--AUI框架中的图标-->
</span>
<input type="file" id="file" class="filepath" onchange="changepic(this)" accept="image/jpg,image/jpeg,image/png,image/PNG">
<!--当vaule值改变时执行changepic函数,规定上传的文件只能是图片-->
</div>
<img src="#" id="img3" />
</body>
</html>
xxxxxxxxxx
function changepic() {
$("#prompt3").css("display", "none");
var reads = new FileReader();
f = document.getElementById('file').files[0];
reads.readAsDataURL(f);
reads.onload = function(e) {
document.getElementById('img3').src = this.result;
$("#img3").css("display", "block");
};
}
#imgPreview {
width: 40%;
height: 180px;
margin: 10px auto 0px auto;
border: 1px solid black;
text-align: center;
#prompt3 {
width: 100%;
position: relative;
#imgSpan {
position: absolute;
top: 60px;
left: 40px;
.filepath {
height: 100%;
opacity: 0;
#img3 {
display: none;