【发布时间】:2019-07-05 09:35:15
【问题描述】:
我正在尝试将图像上传到链接到 Laravel 的公用文件夹的 storage/app/public/ 文件夹。我的filesystems.php 是这样配置的:
'default' => env('FILESYSTEM_DRIVER', 'public')
//rest of the code
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
在我的控制器上,我上传图片:
$file = $request->hasFile('imagem');
$file = $request->file('imagem')->isValid();
$upload = $request->imagem->store('instituicoes');
我希望将文件上传到此路径storage/app/public/instituicoes,但是当我使用此代码时,Laravel 在storage/app 文件夹中创建“instituicoes”文件夹,而不是在我定义为存储路径的storage/app/public/。
【问题讨论】:
-
您是否通过
php artisan storage:link链接了您的存储文件夹?! -
几天前,有人想从 URL 中删除
storage字样。我提供了this 解决方案,但我认为它可以让您了解设置除storage/app/public之外的其他位置以进行链接。 -
我用过
php artisan storage:link -
FILESYSTEM_DRIVER环境变量的值是多少?如果不是public,则默认不存储到公盘 -
它是公开的。这是我在问题中展示的第一行代码。