Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

86
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda