I'm trying to use an input type file with a React Hook Form.
import { Controller, useForm } from "react-hook-form";
import {
Button,
Form, FormText,
Label,
Input,
} from 'reactstrap';
const Test = () => {
const { handleSubmit, control, setValue, formState: { errors }} = useForm();
// I have other inputs and divs. Just showing the file here
return (
<Controller
name="file"
control={control}
render={({ field }) => (
<Input {...field} type="file" id="file" />
)}
/>
);
}
When I submit the form and check the data.file it has only: C:\fakepath\myFile.pdf
const submitForm = (data) => {
console.log(data.file);
}