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

596
Vistas
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 Respuestas
Responde la pregunta

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 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