I am new to react native. I am trying to upload the base64 encoded png to server using formData. but I am keep getting error. network request failed. please help. thanks. here is the code
this.setState({base64: `data:image/jpeg;base64,${result.encoded}`})
console.log(this.state.base64)
formData.append('digital_signature',
{
uri:this.state.base64,
// uri: this.state.singleFileADH1,
name: 'digital_signature.jpg',
type: 'image/*'
}
);
fetch('https://abc.tech/Android_API_CI/upload_multipart_data',
{
method: 'post',
body : formData,
headers: {
'Content-Type': 'multipart/form-data;',
},
}
<SignatureCapture
style={styles.signature}
ref="sign"
onSaveEvent={this._onSaveEvent}
onDragEvent={this._onDragEvent}
showNativeButtons={false}
// minStrokeWidth={-10}
// saveImage={true}
showTitleLabel={false}
viewMode={'portrait'}
/>
const file = {
uri:
Platform.OS == 'android'
? ImageUri.path
: `file://${ImageUri.path}`,
name: 'image.jpg',
type: ImageUri.mime, // e.g. 'image/jpg'
};
formdata.append('user_photo', file);
may this help you