首页 > 解决方案 > 不显示用户头像

问题描述

HTML 标记

<img src="storage/app/avatars/23_avatar1548246815.bmp" alt="">

此路径上已存在文件。但不显示。我也使用了这个php artisan storage:link,但没有工作。错误是服务器错误 403 禁止。

标签: laravellaravel-5

解决方案


根据 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');
  1. 我会做的肯定是使用这种方法
<img src="{{asset('assets/images/image.png')}}">

链接到您的资产文件。

  1. storage/app/avatars应该storage/app/pubic/avatars吗?

推荐阅读