I read that axios is good for image uploading to the database and here is what I got so far:
var photo = {
uri: this.state.userimgSource,
type: this.state.userimgSourceType,
name: file, <-- here
fileName: Image.png
};
var body = new FormData();
body.append('file', photo);
axios({
method: 'post',
url: `https://www.example.com/React/user-image-upload.php`,
data: body,
config: { headers: {'Content-Type': 'multipart/form-data' }}
})
I am new to Axios and I am not sure why I am getting Can't find variable: file
. I tried to put file
into a string and react native will not accept that. If file needs to be a variable, what would I define it with?