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

595
Visualizações
Not able to get file using formik

I am using formik in my react component. one such element is file.

                                          <td>
                                            <div className="mb-10">
                                                <label
                                                    id="attachedFilesLabel"
                                                    className="required form-label" >
                                                    Attached files
                                                </label>
                                                <Field
                                                    type="file"
                                                    className="form-control
                                                    multiple
                                                    placeholder="files"
                                                    name="attachedFile"/>
                                            </div>
                                        </td>

when I print it using alert , alert('values:'+inputParams.attachedFile);

enter image description here

if I print inputParams.attachedFile[0] or inputParams.attachedFile[0].file it comes as undefined.

how can I get file instead of filename so that I can send the same to API.

when I am printing payload then it is coming as filename instead of file it is printing file path.

enter image description here

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

0

Because formik does not support for uploading file , you should do something like this :

<Field  type="file" onChange={(event) => {
  setFieldValue("file", event.currentTarget.files[0]);
}} />

Then get the file on form submit :

     onSubmit={(values) => {
           console.log(values.file)
           }
     }
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