如何通过Laravel后端将React Native上传的图像存储在数据库和图像文件夹中

如何通过Laravel后端将React Native上传的图像存储在数据库和图像文件夹中,laravel,react-native,Laravel,React Native,我从Laravel那里得到了一个或多个我从React native上传的图片的回复,下面是回复代码。如何将名称保存在数据库中,将图像/图像文件保存在文件夹中 images: Array(6) 0: {uri: "file:///data/user/0/com.pardis/cache/react-native-image-crop-picker/IMG_20191226_174428.jpg", width: 52.747252747252745, height: 70, mime: "imag

我从Laravel那里得到了一个或多个我从React native上传的图片的回复,下面是回复代码。如何将名称保存在数据库中,将图像/图像文件保存在文件夹中

images: Array(6)
0: {uri: "file:///data/user/0/com.pardis/cache/react-native-image-crop-picker/IMG_20191226_174428.jpg", width: 52.747252747252745, height: 70, mime: "image/jpeg"}
1: {uri: "file:///data/user/0/com.pardis/cache/react-native-image-crop-picker/IMG_20191226_174441.jpg", width: 52.747252747252745, height: 70, mime: "image/jpeg"}
2: {uri: "file:///data/user/0/com.pardis/cache/react-native-image-crop-picker/IMG_20191226_174453.jpg", width: 52.747252747252745, height: 70, mime: "image/jpeg"}
3: {uri: "file:///data/user/0/com.pardis/cache/react-native-…p-picker/4d6f5a93-ff0c-4987-a014-d17cfbcb5a22.jpg", width: 52.747252747252745, height: 70, mime: "image/jpeg"}
4: {uri: "file:///data/user/0/com.pardis/cache/react-native-image-crop-picker/IMG_20191226_174437.jpg", width: 52.747252747252745, height: 70, mime: "image/jpeg"}
5: {uri: "file:///data/user/0/com.pardis/cache/react-native-…p-picker/e49a5c1c-b03d-4cee-b69b-16c9ee82af5b.jpg", width: 52.747252747252745, height: 70, mime: "image/jpeg"}
length: 6

您没有包含任何控制器代码来显示您已经拥有的内容,但这里有一些东西可以帮助您开始

public function store(Request $request)
{
    //First, get all of the images with temp paths as a collection
    $images = collect($request->files('images'));
    // Next, persist the images in local storage and get their file paths
    $filenames = $images->map(function($image){
      return ['path' => $image->store('public')];  
      // Where public is the name of the storage disk you have defined in config/filesystems.php
    });
    // Finally, bulk insert the image paths in the database
   Image::insert($filenames);
}

您应该显示您的控制器代码或您迄今为止尝试过的内容,以便人们能够帮助您。您应该将该注释作为一个答案,以便其格式良好,然后接受您自己的答案。