0

I am new to React-Native and I'm currently working on a project where the user can upload multiple images to database. I am using react-native-image-picker library to select images from the device memory. However, I don't know how to use the returned images path to upload them to MySQL database using php. What library should I use to upload the images to the database? TIA!

1 Answers1

0

You can create a file usingnew FormData() and use that file to upload.

const name = `${guid()}.jpg` // just to assign a new uuid
const { uri } = response // resonse from ImageViewer
const data = new FormData() // eslint-disable-line
data.append('name', 'avatar') // you can append anyone.
data.append('avatar', {
  uri,
  type: 'image/jpeg', // or photo.type
  name,
})
Vikram Thakur
  • 2,329
  • 1
  • 11
  • 16