laravel - 不显示用户头像
问题描述
HTML 标记
<img src="storage/app/avatars/23_avatar1548246815.bmp" alt="">
此路径上已存在文件。但不显示。我也使用了这个php artisan storage:link
,但没有工作。错误是服务器错误 403 禁止。
解决方案
根据 laravel 文档。
The Public Disk
The public disk is intended for files that are going to be publicly accessible. By default, the public disk uses the local driver and stores these files in storage/app/public. To make them accessible from the web, you should create a symbolic link from public/storage to storage/app/public. This convention will keep your publicly accessible files in one directory that can be easily shared across deployments when using zero down-time deployment systems like Envoyer.
To create the symbolic link, you may use the storage:link Artisan command:
php artisan storage:link
Of course, once a file has been stored and the symbolic link has been created, you can create a URL to the files using the asset helper:
echo asset('storage/file.txt');
- 我会做的肯定是使用这种方法
<img src="{{asset('assets/images/image.png')}}">
链接到您的资产文件。
- 不
storage/app/avatars
应该storage/app/pubic/avatars
吗?
推荐阅读
- python - 使用Python的特殊格式的乘法表
- javascript - 打印从所选日期开始的天数
- c# - 为找到的每个项目更新进度条
- python - 如何将烧瓶输出返回到同一个html页面
- laravel - Laravel 无法获取静态资源地址
- hadoop - Hive 更新期间 HDFS 中发生了什么(真正)?
- java - 如何在 JBoss 中部署没有活动 JMS 配置的 MDB?
- c# - x64 C# 应用程序中结构中的 FieldsOffset
- java - FXMLLoader.load() 在 pre-java 9 样式中工作正常,但在模块中失败
- html - 当导航栏在移动设备上折叠时,背景正文向上滚动