Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions How_to_upload_photo,file_in react-native/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ Fetch supports `multipart/form-data`. You can upload your `formdata` like in web

```jsx
const data = new FormData();

data.append('name', 'testName'); // you can append anyone.
data.append('photo', {
uri: photo.uri,
type: 'image/jpeg', // or photo.type
name: 'testPhotoName'
});

fetch(url, {
method: 'post',
body: data
Expand All @@ -37,14 +39,22 @@ fetch(url, {
only this. If you want many photos

```js
const data = new FormData();
const photos = [photo1, photo2, ...]

photos.forEach((photo) => {
data.append('photo', {
uri: photo.uri,
type: 'image/jpeg', // or photo.type
name: photos.name
});
});

const opts = {
method: 'post',
body: data
}

fetch(url, opts);

```
Expand Down