'How to display image selected on input?

Im trying to display the image selected, but I keep getting the following error:

Not allowed to load local resource:

Any ideas why?

<input type='file' id='fileName' name='fileName' capture='user' accept='image/*'  onchange=\"document.getElementById('myImg').src = window.URL.createObjectURL(this.files[0])\">

<p><img src='#' id='myImg'></p> 


Solution 1:[1]

Agree with @tantoui zakaria. It seems you tried to escape the double quotes with a front slash (/) His code works as expected!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hollman Barahona