UIはこれでよいですか?
HTML
1<input type="file" value="up">
2<div id="img">
3<!--ここに画像をいれる-->
4</div>
参考
javacscript
1<script>
2window.addEventListener('DOMContentLoaded', ()=>{
3 document.querySelector('#up').addEventListener('change',e=>{
4 var target=e.target;
5 var file=target.files[0];
6 if(file !==undefined){
7 var fr = new FileReader();
8 fr.addEventListener('load',e=>{
9 var type=file.type;
10 if(["image/jpeg","image/gif","image/png"].indexOf(type)>-1){
11 var blob=new Blob([e.target.result],{type});
12 var binary=String.fromCharCode.apply("",new Uint8Array(e.target.result));
13 var base64="data:"+file.type+";base64,"+btoa(binary);
14 var img=Object.assign(document.createElement('img'),{src:base64});
15 Object.assign(document.querySelector('#img'),{textContent:""}).appendChild(img);
16 }else{
17 target.value="";
18 document.querySelector('#img').textContent="";
19 }
20 });
21 fr.readAsArrayBuffer(file);
22 }
23 });
24});
25</script>
26<input type="file" value="up" id="up" accept="image/*">
27<div id="img">
28<!--ここに画像をいれる-->
29</div>