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

111
Vistas
Why I get empty file input after submit form?

There is a function that triggers the input file and shows previews:

$(document).on("change", "#Multifileupload", function() {
    var MultifileUpload = document.getElementById("Multifileupload");

    if (typeof FileReader != "undefined") {
        var MultidvPreview = document.getElementById("MultidvPreview");

        console.log(MultifileUpload.files);

        var images = Array.prototype.slice.call(
            MultifileUpload.files,
            0,
            upload_product_images_comment_total
        );

        for (
            var i = 0; i < images.length &&
            upload_product_images_comment_loaded <=
            upload_product_images_comment_total; i++
        ) {
            var file = images[i];
            var reader = new FileReader();

            reader.onload = function(e) {
                var img = document.createElement("img");
                var span = document.createElement("span");

                span.classList.add("remove_image");
                span.classList.add("icon-close");

                img.src = e.target.result;
                img.classList.add("Multifileupload_image");

                var position = upload_product_images_comment_loaded + 1;

                if (position > upload_product_images_comment_total - 1) {
                    var li = document.createElement("li");
                    $(".upload-photo-thumb").hide();
                    MultidvPreview.prepend(li);
                    MultidvPreview.children[0].appendChild(img);
                    MultidvPreview.children[0].appendChild(span);
                } else {
                    MultidvPreview.children[position].appendChild(img);
                    MultidvPreview.children[position].appendChild(span);
                }

                upload_product_images_comment_loaded++;
            };
            reader.readAsDataURL(file);
        }

        MultifileUpload.value = '';

    } else {
        alert("This browser does not support HTML5 FileReader.");
    }
});

The HTML input is:

<input type="file" id="Multifileupload" multiple="" name="file" size="40" accept=".png, .jpg, .jpeg, .gif">

Problem is when I choose some images and submit form I get empty file field in request:

csrf_mds_token=b2c47be75606853053acbbcf48c6280c&review=wreewrewrewrwrwrwrwr&rating=5&product_id=6&file=&sys_lang_id=1
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can not send files with the GET method, you have to use POST and add enctype="multipart/form-data" to your form tag:

<form method="POST" enctype="multipart/form-data">
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