您的位置:首页 > 理论基础 > 计算机网络

xmlhttprequest请求

2016-03-23 10:08 302 查看
上传

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: