<img id="testImage">
<input type="file" onchange="readFile(this)">
<script>
function readFile(input) {
let reader = new FileReader();
reader.readAsDataURL(input.files[0]);
reader.onload = function() {
document.getElementById('testImage').src = reader.result;
};
}
</script>