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

177
Visualizações
How can I upload only the file in input type file without sending the entire form?

I'm writing a survey and I have a form with lot of inputs. The first ten are for personal data like and images, the others, in variable number, will be the questions of my survey.

I want the user to upload multiple images, but I'd like he could even remove some images right before. I know I can't remove files from the file object, so I had this idea: if I could upload the image right in the moment the user chooses (the on input event, or maybe on load) without sending the form I will store the image in a temporary folder (and with a js function I'll handle the file inputs to replace with a new one etc.).

So, finally, the question is: is there a way to upload a single input, maybe with ajax, without sending all inputs?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use ajax like this

   let formData = new FormData()
    var d = $('#fileid')[0].files[0] // field name 

    formData.append('fileid', d);
    formData.append('inputname', value);

    $.ajax({
        url: '/yourroute',
        method: 'POST',
        contentType: false,
        processData: false,
        data: formData,
        success: function(res){
            console.log('successfully')
        },
        error: function(){
            console.log('error')
        }
    })
about 4 years ago · Juan Pablo Isaza Relatório
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