我正在尝试将文件上传到最近工作的公共文件夹,但现在显示以下错误:
磁盘 [public] 没有配置的驱动程序。
我尝试在config/filesystems.php中检查配置的驱动程序,但是它已经在那里设置了。我不知道问题可能出在哪里。
上传代码:
public function upload(ProductImageRequest $request, Product $product)
{
$image = $request->file('file');
$dbPath = $image->storePublicly('uploads/catalog/'.$product->id, 'public');
if ($product->images === null || $product->images->count() === 0) {
$imageModel = $product->images()->create(
['path' => $dbPath,
'is_main_image' => 1, ]
);
} else {
$imageModel = $product->images()->create(['path' => $dbPath]);
}
return response()->json(['image' => $imageModel]);
}
config/filesystems.php中的代码
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],