The below video will explain how to validate image and show preview in browser using javascript
<iframe width="560" height="315" src="https://www.youtube.com/embed/QxRIyuNNzoM" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> Code With Sundeep