I'm using a form control component to pass an image to an API endpoint via an AJAX call. So far, I'm unable to find information on how to actually target the actual file data.
Just using file upload.. You can't read files, directories in client side with javascript. You need to upload it first and read file path in server side then send response of file's path from server. @RenjithStephen You can use a FileReader if you want to use the data directly in the browser.
Overview. The <FormControl> component renders a form control with Bootstrap styling. The <FormGroup> component wraps a form control with proper spacing, along with support for a label, help text, and validation state. To ensure accessibility, set controlId on <FormGroup> , and use <FormLabel> for the label.
You can get the file via onChange:
<FormControl type="file" onChange={(e) => console.log(e.target.files)}/>
where e.target.files is a FileList containing 0 or 1 files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With