【问题标题】:How to upload images from react naitve to mysql database?如何将图像从 React Native 上传到 mysql 数据库?
【发布时间】:2018-07-12 15:49:01
【问题描述】:

我是 React-Native 的新手,我目前正在开发一个用户可以将多个图像上传到数据库的项目。我正在使用 react-native-image-picker 库从设备内存中选择图像。但是,我不知道如何使用返回的图像路径使用 php 将它们上传到 MySQL 数据库。我应该使用什么库将图像上传到数据库? 蒂亚!

【问题讨论】:

标签: php mysql react-native react-native-image-picker


【解决方案1】:

您可以使用new FormData() 创建文件并使用该文件上传。

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,
})

【讨论】:

    猜你喜欢
    • 2018-01-14
    • 1970-01-01
    • 2012-07-23
    • 2021-07-30
    • 2018-03-28
    • 2022-10-18
    • 1970-01-01
    • 2016-07-21
    相关资源
    最近更新 更多