简体   繁体   English

laravel voyager 子域图像未显示

[英]laravel voyager subdomain image not showing

voyager project is installed on a subdomaine. voyager 项目安装在子域上。 https://sub.domainname.com/ , There is no problem in uploading images in local and I can show them But when i try it on hosting, the pictures appear broken, no matter what i did https://sub.domainname.com/ ,在本地上传图片没有问题,我可以显示它们但是当我在主机上尝试时,无论我做什么,图片都会出现损坏

APP URL应用网址

APP_URL=https://sub.domainname.com

Config/fileSystems配置/文件系统

'disks' => [

    'local' => [
        'driver' => 'local',
        'root' => storage_path('app'),
    ],

    'public' => [
        'driver' => 'local',
        'root' => storage_path('app/public'),
        'url' => env('APP_URL').'/storage',
        'visibility' => 'public',
    ],

    's3' => [
        'driver' => 's3',
        'key' => env('AWS_ACCESS_KEY_ID'),
        'secret' => env('AWS_SECRET_ACCESS_KEY'),
        'region' => env('AWS_DEFAULT_REGION'),
        'bucket' => env('AWS_BUCKET'),
        'url' => env('AWS_URL'),
        'endpoint' => env('AWS_ENDPOINT'),
        'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
    ],

],

after uploading an image its image on the media menu上传图像后,它的图像在媒体菜单上

enter image description here在此处输入图像描述

Did you publish the storage folder link?您是否发布了存储文件夹链接? php artisan storage:link

Update Question更新问题

I'm uploading from my subdomain project to the storage folder in the root directory this way I created a voyager storage in我正在从我的子域项目上传到根目录中的存储文件夹,这样我创建了一个航海者存储

'voyager' => [
            'driver' => 'local',
            'root' => '/home/username/public_html/storage/app/public',
            'url' => 'https://website.com/storage',
            'visibility' => 'public',
        ]

In my config/voyager.php file, I gave the disk I created custom.在我的 config/voyager.php 文件中,我给了我自定义创建的磁盘。

'storage' => [
        'disk' => 'voyager',
    ],

In this way, I can send images to the root directory of the project under public_html, but my images are still not visible on voyager.这样我就可以将图片发送到项目根目录public_html下,但是我的图片在voyager上还是看不到的。 The path of the images looks like this;图像的路径如下所示;

https://website.com/storage/works/July2022/5w9ONuhB1VgQFLj9hGJH.png

Sorry, but is all your code inside the public_html folder?抱歉,您的所有代码都在 public_html 文件夹中吗? I mean, is there all including routes, storage, app, etc.?我的意思是,是否包括路线、存储、应用程序等?

This may affect the way your application considers where is the public folder.这可能会影响您的应用程序考虑公用文件夹在哪里的方式。 So you can open Tinker or add a log to see if the public_path() function is returning the correct path.因此,您可以打开 Tinker 或添加日志以查看 public_path() 函数是否返回正确的路径。 If not, then you should instruct your application to redirect the path to the right folder or change the structure of your project to one more convenient/secure.如果没有,那么您应该指示您的应用程序将路径重定向到正确的文件夹或将项目的结构更改为更方便/安全的结构。

Also is the one from the example the subdomain?示例中的那个也是子域吗? As it looks like a main domain.因为它看起来像一个主域。

PS: I don't know much about the cons, but most people doesn't recommend exposing paths here, like your project's domain or structure, as you don't know what can people do with that information. PS:我不太了解缺点,但是大多数人不建议在这里公开路径,例如您的项目的域或结构,因为您不知道人们可以用这些信息做什么。

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

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