我会将图像上传到存储文件夹storage/app/public,但我也会添加其他文件夹,以便以对我更有用的方式存储它们
C:\xampp\htdocs\rps\storage\app\public\images\user-profile
我设法保存它们没有任何问题,但现在我不知道如何在我尝试过的.blade.php文件中访问它们:
src="storage/images/user-profile/standard/default.png"C:\xampp\htdocs\rps\storage\app\public\images\user-profile\standard\default.png
或
src="storage/images/user-profile/standard/{{$person->avatar}}"C:\xampp\htdocs\rps\storage\app\public\images\user-profile\standard\1558700163.jpg
但这对我没用,任何人都能帮上忙。我想我的道路是错的
我还需要添加public/storage文件夹吗?
发布于 2019-05-24 21:05:46
在config/filesystems.php中配置一个新磁盘,如下所示:
'images' => [
'driver' => 'local',
'root' => storage_path('images'),
],然后获取URL:
$url = Storage::disk('images')->url('file.jpg');并获取文件内容:
$contents = Storage::disk('images')->get('file.jpg');您也可以使用storage_path()帮助器。因此,在您看来,这应该是可行的:
src="{{storage_path('images/user-profile/standard/default.png')}}"有关更多信息,请阅读docs。
https://stackoverflow.com/questions/56293116
复制相似问题