Home > other >  laravel voyager subdomain image not showing
laravel voyager subdomain image not showing

Time:07-06

voyager project is installed on a subdomaine. 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

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

CodePudding user response:

Did you publish the storage folder link? php artisan storage:link

CodePudding user response:

Sorry, but is all your code inside the public_html folder? 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. 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.

CodePudding user response:

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.

'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. The path of the images looks like this;

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