react-native-image-picker-form
react-native-image-picker-form copied to clipboard
how to get the image data to post ?
Hi there,
Thank you for the image picker form.
I want to get the selected image data to post in the API in order to store in database. May i know how to get the image data ?
Hi @sgkalyans ! On the state object the image data it's saved, specifically on the field you provided the factory.
you can use FormData() and just put the value in uri to send it to server.
const uriPhoto = this.state.value['image'];//value of image
const uriPart = uriPhoto.split('.');
const fileExtension = uriPart[uriPart.length - 1];
data.append('photo',{uri: uriPhoto, type: 'image/'+fileExtension, name: 'photo'+'.'+fileExtension})