<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input type="file">
<img src="" alt="">
<script>
document.querySelector('input').addEventListener('change', function () {
let file = document.querySelector('input').files[0]
console.log(file);
let base64 = new FileReader()
base64.readAsDataURL(file)
base64.onload = function () {
let a = this.result
console.log(a);
document.querySelector('img').src = a
}
})
</script>
</body>
</html>
上传图片base64
最新推荐文章于 2024-07-15 00:00:26 发布
关键词由CSDN通过智能技术生成