How to upload file to server using react-native

后端 未结 7 1320
渐次进展
渐次进展 2020-12-12 20:36

I am developing a app where i need to upload an image to the server. Based on the image i get a response which i need to render?.

Can you please help me how to uploa

相关标签:
7条回答
  • 2020-12-12 21:30

    There is file uploading built into React Native.

    Example from React Native code:

    var photo = {
        uri: uriFromCameraRoll,
        type: 'image/jpeg',
        name: 'photo.jpg',
    };
    
    var body = new FormData();
    body.append('authToken', 'secret');
    body.append('photo', photo);
    body.append('title', 'A beautiful photo!');
    
    var xhr = new XMLHttpRequest();
    xhr.open('POST', serverURL);
    xhr.send(body);
    
    0 讨论(0)
提交回复
热议问题