Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upload file to server using react-native

Tags:

react-native

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 upload an image using react-native?.

like image 459
manjunath24242424 Avatar asked Apr 07 '15 10:04

manjunath24242424


People also ask

How do I upload a file to a server?

Right-click the folder and select “Upload other file here. . .“. Browse the server for the file you want to upload. Select the file and click Open. Now, you will see the file in the folder location on the server.


1 Answers

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); 
like image 53
Dev01 Avatar answered Sep 25 '22 01:09

Dev01