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!
Asked
Active
Viewed 753 times
0
-
Do you want to store the image in some folder/s3 and store the only name in your MySQL table? – Vikram Thakur Apr 02 '19 at 03:28
-
Just flow this: https://reactnativecode.com/upload-image-to-server-using-php-mysql/ – Saeid Nov 13 '19 at 09:38
1 Answers
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