Get all contacts from phonebook and upload to server but got following error.
While append image in request body FormData
Image may be NSFW.
Clik here to view.
Tried code
pass file url contact thumbnailPath
const path = con.thumbnailPathbody.append('image', { uri: path, type: 'image/jpeg', name: 'photo.jpg', type: 'multipart/form-data'})
Tried code
pass file url contact thumbnailPath without "file://"
const path = con.thumbnailPath.replace('file://', '')body.append('image', { uri: path, type: 'image/jpeg', name: 'photo.jpg', type: 'multipart/form-data'})
Tried code
check file exist on path or not with using react-native-fs
if (con.thumbnailPath != '') { let isExist = RNFS.exists(con.thumbnailPath) if (isExist) { const path = con.thumbnailPath.replace('file://', '') console.log("Exist", path) body.append('image', { uri: path, type: 'image/jpeg', name: 'photo.jpg', type: 'multipart/form-data' }) }}
Request
fetch(url, { method: 'POST', headers: {'Authorization': token,'token': token }, body: params }).then((res) => res.json()).then((json) => { console.log("RESPONSE:- ", json) if (json.response[0].status == 'false') { let msg = json.response[0].response_msg callback(new Error(msg), json.response[0]) } else { callback(null, json.response[0]) }}).catch((err) => { console.log(err) callback(err, null)})