简体   繁体   English

Laravel Voyager 不显示图像

[英]Laravel Voyager not showing images

I have created a Laravel app using installatron on godaddy.com (shared hosting).我在 godaddy.com(共享主机)上使用 installatron 创建了一个 Laravel 应用程序。 After installing Voyager the default admin avatar is not showing.安装 Voyager 后,默认管理员头像未显示。 The storage link is automatically created by Voyager.存储链接由 Voyager 自动创建。 But when I open the admin panel voyager tries to get admin avatar from [app_url]/storage/users/default.png and receives a 404. The avatar is at [app_url]/public/storage/users/default.png但是当我打开管理面板时,voyager 尝试从[app_url]/storage/users/default.png获取管理员头像并收到 404。头像位于[app_url]/public/storage/users/default.png

Screenshot截屏

Versions: Laravel: 5.8 Voyager: 1.3版本: Laravel: 5.8航海者: 1.3

如果使用 localhost,请将端口号放入 .env 文件中

APP_URL=http://localhost:port_number

I've faced the exact same issue before, after checking the APP_URL, go ahead and execute我之前遇到过完全相同的问题,在检查 APP_URL 之后,继续执行

php artisan config:clear

After that try again.之后再试一次。

If it doesn't work, delete the symlink storage in public/ and execute如果不起作用,请删除 public/ 中的符号链接存储并执行

php artisan storage:link

Please check if the APP_URL in your .env file is correct.请检查您的 .env 文件中的 APP_URL 是否正确。

That it equals the domain-name you bought at godaddy and also the protocol (HTTP or HTTPS).它等于您在 godaddy 购买的域名以及协议(HTTP 或 HTTPS)。

Simply change the 'APP_URL' variable into the .env file to your localhost route.只需将 'APP_URL' 变量更改为 .env 文件到您的 localhost 路由。

For example:例如:

APP_URL=http://127.0.0.1:8000

I was facing this issue today我今天面临这个问题

in my case 3 steps:在我的情况下 3 个步骤:

1- correct App_URL in .env file (do`nt forget port number ) example: 1- .env 文件中的正确 App_URL(不要忘记端口号)示例:

APP_URL=http://127.0.0.1:8000

2- delete storage file from [project path]\public 2- 从 [项目路径]\public 中删除存储文件

3- run: php artisan storage:link 3-运行: php artisan storage:link

enjoy:)请享用:)

I solved my problem in local try with adding port to APP_URL .我在本地尝试将端口添加到APP_URL解决了我的问题。 But in the server problem was the "Storage" folder which is in public directory.在服务器问题是公共目录中的“存储”文件夹。

UPDATE Feb 2022 please notice the symbolic link must be existed in your root 2022 年 2 月更新,请注意符号链接必须存在于您的根目录中

在您的 .env 文件中,替换应用 URL。

APP_URL=http://localhost:port 

I had to change the setting in filesystems.php .我不得不更改filesystems.php中的设置。

'url' => env('APP_URL').'/nameOfMyRootFolder/storage/app/public',

Then it was able to resolve the image link correctly.然后它能够​​正确解析图像链接。

更改 filesystems.php 中的设置,disks -> public -> "url => env('APP_URL').'/public/storage'"

请检查 .env 文件中的 APP_URL=<> 它应该基本上像

APP_URL=http://localhost:8000

Check APP_URL in .env file, make sure that APP_URL in .env file is to the public folder of your project检查 .env 文件中的 APP_URL,确保 .env 文件中的 APP_URL 指向您项目的公共文件夹

APP_URL=http://localhost/your-project-name/public/ APP_URL=http://localhost/your-project-name/public/

APP_URL setting worked for me. APP_URL 设置对我有用。 I'm running the app in a container so I have to put the port used from my host not 8000. I have port 8000 mapped to 8186, so I have to put APP_URL=http://localhost:8186我在容器中运行应用程序,所以我必须把我的主机使用的端口不是 8000。我有端口 8000 映射到 8186,所以我必须把 APP_URL=http://localhost:8186

如果您使用的是sails,请尝试运行:

 sail artisan storage:link

work for me:为我工作:

image see in url http://localhost:8000/storage/users/default.png but dont in /admin panel (http://localhost/storage/users/default.png 404) its a port problem with storage图片见 url http://localhost:8000/storage/users/default.png但不在 /admin 面板中(http://localhost/storage/users/default.png 404)这是存储的端口问题

change in config/app to将配置/应用更改为

'url' => env('APP_URL', 'http://localhost:8000')

If you're still wonder why, check this answer in voyager issues如果您仍然想知道为什么,请查看航海者问题中的这个答案

Since FILESYSTEM_DRIVER was not defined by default in Laravel the public storage was used, but in Laravel 8.5.19 the default value was added.由于在 Laravel 中默认未定义 FILESYSTEM_DRIVER,因此使用公共存储,但在 Laravel 8.5.19 中添加了默认值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM