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

91
Vistas
update input field by file and dropzone

I am using dropzone.js and I need to return back selected files in my view in hidden inputs but I'm getting [object File] in order to solve that I've tried to update my input values by document.getElementsByName("documents["+index+"][data]").value = f after half of second yet I'm getting same error!

Here is my code

var myDropzone = new Dropzone("#dropzone-form", {
    //.....
    init : function() {
        this.on("addedfile", function(file) {
            docs.push(file); // make array of selected files
            setTimeout(async function() {
                addDocsToForm(docs); // call function to return inputs in view
            }, 2000);
        });
    }
    //....
});

async function addDocsToForm(docs) {
    // loop array files
    docs.forEach(function(myD, index) {
        var dd = myD;

        dd.previewElement.classList.add("dz-success");
        // return inputs with file data (currently getting `[object File]`)
        $('#botofform').append('<input name="documents['+index+'][data]" value="'+ dd +'">');

        // make new file from file data
        var f = new File([""], dd['name'], {type: dd['type'], lastModified: dd['lastModified']});
        setTimeout(async function() {
            // update inputs value with file data (currently getting `[object File]`)
            document.getElementsByName("documents["+index+"][data]").value = f;
        }, 500);
        dd.previewElement.classList.add("dz-complete");
        console.log('Done');
    });
}

PS: I can get my files data by converting them into base64 (not interested) but due to server limits request will become so big that server always return 413 error so I decided to append ordinary input fields and send files just like when we don't use dropzone.

Any idea?

about 4 years ago · Juan Pablo Isaza
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