Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

176
Vistas
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> 
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

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

about 4 years ago · Juan Pablo Isaza Denunciar

0

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])"

jsfiddle

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda