代码之家  ›  专栏  ›  技术社区  ›  Aleks Per

使用Laravel 5.8将base64字符串另存为文件到云存储

  •  0
  • Aleks Per  · 技术社区  · 3 年前

    我需要将base64字符串作为文件存储到云存储,所以我编写代码:

    public function store_img(Request $request)
        {
    
    
    $image = $request->img;  // my base64 as a text
    $image = str_replace('data:image/png;base64,', '', $image);
    $image = str_replace(' ', '+', $image);
    $image = base64_decode($image);
    
    $path = $image->store('catalogs','spaces');
    Storage::disk('spaces')->setVisibility($path, 'public');
         
     return response()
                ->json(['url' => $path]);
    
                    }
    

    但我有一个错误: 调用字符串上的成员函数store()

    如何解决这个问题?如何将此字符串另存为PNG图像到云存储。

    0 回复  |  直到 3 年前
    推荐文章