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);
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.
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)
}
}