<label class="labelt" for="selectIer">
<div class="up_photo_box">
<img id="previ" />
上传封面图
<input id="selectIer" style="margin-left: 10px;" type="file" accept="image/*" name="entrant" placeholder="请输所在学校" />
<script type="text/javascript">
document.getElementById('selectIer').addEventListener('change',()=>{
const file = document.getElementById('selectIer');
const fileObj = file.files[0];
const windowURL = window.URL || window.webkitURL;
const img = document.getElementById('previ');
if(file && fileObj) {
const dataURl = windowURL.createObjectURL(fileObj);
img.setAttribute('src',dataURl);
}
},false)
</script>
</div>
</label>
改变input type="file" 样式
最新推荐文章于 2022-09-23 21:20:48 发布