更改上传图片的目录

Change directory for uploading image

如何更改上传图片的目录。 我想上传到App/public/files文件夹。

我的代码在这里:

    public function update(Request $request, Organigramme $organigramme)
    {
    $id = $organigramme->id;
    $organigramme = Organigramme::find($id);
    $organigramme->matricule = $request->input('matricule');

    if ($request->has('profile_image'))
    {
        $image = $request->file('profile_image');
        $name = str_slug($request->input('matricule'));
        $folder = '/uploads/images/';
        $filePath = $folder . $name. '.' . $image->getClientOriginalExtension();
        $this->uploadOne($image, $folder, 'public', $name);

        $organigramme->profile_image = $filePath;
        $organigramme->save();
    }
    return view( 'admin.organigrammes.show', compact('organigramme'));
   }

public function uploadOne(UploadedFile $uploadedFile, $folder = null, $disk = 'public', $filename = null)
{
    $name = !is_null($filename) ? $filename : str_random(25);

    $file = $uploadedFile->storeAs($folder, $name.'.'.$uploadedFile->getClientOriginalExtension(), $disk);

    return $file;
}

在 config/filesystems 文件中添加一个新的保存 path.For 示例:

  'images' => [
        'driver' => 'local',
        'root' => base_path().'/app/public/files',
    ],

在代码本身中,使用以下代码保存:

存储::磁盘('images')->put($path, $image);