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>
CodePudding user response:
You have error in your onchange event, i tried the code and it works
onchange="document.getElementById('myImg').src = window.URL.createObjectURL(this.files[0])"
CodePudding user response:
Agree with @tantoui zakaria. It seems you tried to escape the double quotes with a front slash (/) His code works as expected!
