如何将图片上传到 public 文件夹而不是存储?
how to upload image to public folder not to storage?
我想将图像上传到 imgs 文件夹内的 public 文件夹,所以我尝试将以下内容添加到 cofig/filesystems。php:
'pub' => [
'driver' => 'local',
'root' => '/imgs',
'url' => env('APP_URL').'/public',
'visibility' => 'public',
]
但现在当我使用 $d->storeAs('products', $name.$ext, ['storage' => 'pub']);
时,图像保存在 storage/app/public/imgs/products 而不是 public/imgs/products
我如何将它们存储在 public 而不是存储中?
在 Laravel 5 中,您现在必须在 config/filesystems 中执行此操作。php .
您可以像这样添加一个新磁盘:
'disks' => [
'uploads' => [
'driver' => 'local',
'root' => public_path(), // previously storage_path();
],
]
然后执行以下操作来使用它:
Storage::disk('uploads')->put('filename', $file_content);
参考文献:
https://laracasts.com/discuss/channels/laravel/change-the-storage-path-to-public-laravel-53
我想将图像上传到 imgs 文件夹内的 public 文件夹,所以我尝试将以下内容添加到 cofig/filesystems。php:
'pub' => [
'driver' => 'local',
'root' => '/imgs',
'url' => env('APP_URL').'/public',
'visibility' => 'public',
]
但现在当我使用 $d->storeAs('products', $name.$ext, ['storage' => 'pub']);
时,图像保存在 storage/app/public/imgs/products 而不是 public/imgs/products
我如何将它们存储在 public 而不是存储中?
在 Laravel 5 中,您现在必须在 config/filesystems 中执行此操作。php .
您可以像这样添加一个新磁盘:
'disks' => [
'uploads' => [
'driver' => 'local',
'root' => public_path(), // previously storage_path();
],
]
然后执行以下操作来使用它:
Storage::disk('uploads')->put('filename', $file_content);
参考文献:
https://laracasts.com/discuss/channels/laravel/change-the-storage-path-to-public-laravel-53