我需要将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图像到云存储。