Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

594
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!