'How to submit a form with a file input and several text field inputs?

Is it possible to embed a file attachment in a JSON Object. I have a Form in react (class component), which has several text field inputs and a file attachment. I want to send a JSON Object wrapping all these form data (including the file attachment) to the backend.

How can i submit the form with text fields and a file.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source