Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 无法将图像上载到S3存储桶_Laravel_Amazon S3_File Upload - Fatal编程技术网

Laravel 无法将图像上载到S3存储桶

Laravel 无法将图像上载到S3存储桶,laravel,amazon-s3,file-upload,Laravel,Amazon S3,File Upload,我正在尝试使用vue js和laravel将图像上传到Amazon s3 bucket。但当我上传时,会出现以下异常:- 这是我在控制器中写的上传文件的内容 public function addProperty(Request $request) { $property = new Property; $property->title = request('title'); $property->property_type = request('typ

我正在尝试使用vue js和laravel将图像上传到Amazon s3 bucket。但当我上传时,会出现以下异常:-

这是我在控制器中写的上传文件的内容

public function addProperty(Request $request)
{

    $property = new Property;
    $property->title = request('title');
    $property->property_type =  request('type');
    $property->property_sub_type = request('subtype');
    $property->address = request('address');
    $property->property_index = 400;

    #$property->save();

    if ($request->hasFile('image')) {


        $fileNameWithExtension = $request->file('image')- >getClientOriginalName();
        $fileName = pathinfo($fileNameWithExtension, PATHINFO_FILENAME);
        $extension = $request->file('image')->getClientOriginalExtension();

        $fileNameStore =$fileName.'_'.time().'_'.'.'.$extension;
        $disk = Storage::disk('s3');
        $disk->put($fileNameStore, fopen($request->file('image'), 'r+'), 'public');

        $profilePicImageUri = Storage::disk('s3')->url($fileNameStore);
        dd($profilePicImageUri);
        return $profilePicImageUri;

    }

}
以下是我在Vue中所做的工作

onSubmit(){
            let self = this;
            let data = new FormData();
            data.append('image',this.file);
            data.append('title',this.propertyTitle);
            data.append('type',this.type);
            data.append('subtype',this.subtype);
            data.append('lat',this.lat);
            data.append('long',this.long);
            data.append('address',this.address);

            let config = {
                    headers:{
                        'Content-Type' : 'multipart/form-data'
                    }
            }
            axios.post(baseUrl + "api/admin/addproperty",data,config)
                .then(function (response) {
                    console.log(response);
            }).catch(function (error) {
                {
                    console.log(error);
                }
            })

        },
我已经在env文件中设置了aws配置。这是我的配置

AWS_ACCESS_KEY_ID=XXXX
AWS_SECRET_ACCESS_KEY=XXX
AWS_DEFAULT_REGION=eu-central-1
AWS_BUCKET= php-laravel-upload
AWS_URL = https://php-laravel-upload.s3.eu-central-1.amazonaws.com
我不明白我做错了什么。有人能帮我吗?

试试看

 if ($request->hasFile('image')) {
        $fileInstance = $request->file('image');

        $fileNameStore = $fileInstance->getClientOriginalName().'_'.time().'_.'.$fileInstance->getClientOriginalExtension();
        Storage::disk('s3')->put($fileNameStore, $fileInstance, 'public');

        $profilePicImageUri = Storage::disk('s3')->url($fileNameStore);
      //  dd($profilePicImageUri);
        return $profilePicImageUri;

    }

@阿披舍克米什拉然后发布你的桶名