上传
var xhr = new XMLHttpRequest(); xhr.open('POST', 'http://posttestserver.com/post.php'); xhr.onload = () => { if (xhr.status !== 200) { AlertIOS.alert( 'Upload failed', 'Expected HTTP 200 OK response, got ' + xhr.status ); return; } // upload succeeded ... }; var formdata = new FormData(); formdata.append(photo, {type: "image/jpeg", name: ____, uri: ______ }); if (xhr.upload) { xhr.upload.onprogress = (event) => { console.log('upload onprogress', event); if (event.lengthComputable) { this.setState({uploadProgress: event.loaded / event.total}); } }; } xhr.send(formdata);
https://github.com/marcshilling/react-native-image-picker/issues/31