You can use FormData to send form data using AJAX, including files. This is for you if you have to manually add files, you don't take them from a form, for some reason. This snippet is a react component witch does exactly that.
Source code viewer
import React from 'react'; import ReactDOM from 'react-dom'; class MyComponent extends React.PureComponent { constructor(props) { super(props); this.form = React.createRef(); this.filePhoto = React.createRef(); } handleSubmit(event) { event.preventDefault(); const formData = new FormData(ReactDOM.findDOMNode(this.form.current)); formData.append('file_photo', this.filePhoto.current.files[0]); } render() { return <> <form onSubmit={this.handleSubmit} ref={this.form}> <input type="submit" value="Submit"> </form> <input type="file" ref={this.filePhoto} /> </>; } }Programming Language: ECMAScript