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

186
Vistas
TypeError: no se pudo ejecutar 'readAsDataURL' en 'FileReader': el parámetro 1 no es del tipo 'Blob'

He estado luchando con esto durante un par de días. No sé por qué sigue diciendo que mi archivo no es un tipo de blob. ¿Alguna ayuda?

HTML ABAJO

 <form style="padding-top:10px;" method="post" action="upload.php" enctype="multipart/form-data"> <input style="padding-bottom: 20px;" type="file" id="file" name="file" onchange="fileValidation(this);"> <div id="responsefromfileupload" value=""></div> </form>

JAVASCRIPT A CONTINUACIÓN

 function fileValidation(reader) { var file = $("input[type=file]").get(0).files[0]; var fileInput = document.getElementById('file'); var filePath = fileInput.value; // Allowing file type var allowedExtensions = /(\.jpg|\.jpeg|\.png|\.gif)$/i; if (!allowedExtensions.exec(filePath)) { $("#responsefromfileupload").replaceWith(`<div style="width: 50%;" class="alert alert-danger" role="alert"> This image file type is not accepted!</div>`); } if (allowedExtensions.exec(filePath)) { var reader = new FileReader(); reader.onload = function () { $("#previewImg").attr("src", reader.result); $("#previewImg").attr("margin-left", "25%"); } } reader.readAsDataURL(file); }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

 function fileValidation(event) { var file = event.target.files[0]; var fileInput = document.getElementById('file'); var filePath = fileInput.value; // Allowing file type var allowedExtensions = /(\.jpg|\.jpeg|\.png|\.gif)$/i; if (!allowedExtensions.exec(filePath)) { $("#responsefromfileupload").replaceWith(`<div style="width: 50%;" class="alert alert-danger" role="alert"> This image file type is not accepted!</div>`); } if (allowedExtensions.exec(filePath)) { var reader = new FileReader(); reader.onload = function () { $("#previewImg").attr("src", reader.result); $("#previewImg").attr("margin-left", "25%"); } } reader.readAsDataURL(file); }
 <form style="padding-top:10px;" method="post" action="upload.php" enctype="multipart/form-data"> <input style="padding-bottom: 20px;" type="file" id="file" name="file" onchange="fileValidation(event);"> <div id="responsefromfileupload" value=""></div> </form>

La plantilla que puede usar - elimine el espacio entre < y !--

< !-- comenzar fragmento: js ocultar: falso consola: verdadero babel: falso -->

< !-- idioma: lang-js -->

< !-- idioma: lang-html -->

< !-- idioma: lang-css -->

< !-- fragmento final -->

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