ZLSwipeableView
ZLSwipeableView copied to clipboard
unable to upload image on server using axios in react native
i am trying to upload a image with my other text data to server. but text data is uploading but image never uploads. here is my code
const fileToUpload = selectedImage1;
const data = new FormData();
data.append('image', 'Image Upload');
data.append('file_attachment', fileToUpload);
fetch('URL', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
first_name: textInputFname,
last_name: textInputLname,
email: textInputEmail,
password: textInputPassword,
phone: textInputPhone,
address: textInputAddress,
type: checked=='first'?1:2,
company_name: textInputCoName,
company_address: textInputCoAddress,
company_tax_number: textInputCoTaxNum,
extra_info: textInputExtraInfo,
image: data
})
}).then((response) => response.json())
selectedImage1 is the image path that i selected from image picker.