Sherzad's avatar

Unable to upload image (React native, Laravel)

I have been trying this for a while but no success

back-end (Laravel)

public function createInspection(Request $request) {
       $path = Storage::disk('public')->putFile('bin_images', new File($request->file('image')));
    return $path;    
    }

react-native

data.append("image", {
      uri: this.state.images[0].path,
      type: this.state.images[0].mime,
      size: this.state.images[0].size,
      name: filename
    });

this.props.sendInspection(data)

service

const res = await axios.post(url, data, {
        headers: {
          Authorization: `Bearer ${token}`,
          Accept: "application/json",
          "Content-Type": "multipart/form-data"
        }

im not sure if it's something to do with path not being recongnized (ios image path) e.g. path : /private/var/mobile/Containers/Data/Application/B6FEB0FD-F9C8-4088-B15F-99D27A818C76/tmp/react-native-image-crop-picker/7BD81594-30E0-4E00-919C-4F353BBDE46F.jpg

I get this error

message: "The file "" does not exist", exception: "Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException"
0 likes
0 replies

Please or to participate in this conversation.