skip to Main Content

my question may not be fully understood from the title, I apologize for that.
The images uploaded in my cPanel are not loaded at the address where I run the php artisan serve command, I get a 404.

I tried php artisan storage:link but it didn’t work. I played around with filesystem.php and it didn’t work again. I didn’t see any problems with my file permissions either. Am I not doing something I don’t know about?
I would be happy if you help

here codes:

<?php

return [

    'default' => 'local',


    'disks' => [

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

        'public' => [
            'driver'     => 'local',
            'root'       => storage_path('app/public'),
            'url'        => 'http://127.0.0.1:8000/storage',
            'visibility' => 'public',
            'throw'      => false,
        ], 

        'custom' => [
            'driver'     => 'local',
            'root'       => public_path('storage'),
            'url'        => 'http://127.0.0.1:8000/public/storage',
            'visibility' => 'public',
            'throw'      => false,
        ],

        'chat' => [
            'driver'     => 'local',
            'root'       => public_path('storage/chat'),
            'url'        => 'http://127.0.0.1:8000/public/storage/chat',
            'visibility' => 'public',
            'throw'      => false,
        ],
        
                    'wasabi' => [
                'driver' => 'wasabi',
                'key' => env('WASABI_KEY'),
                'secret' => env('WASABI_SECRET'),
                'region' => env('WASABI_REGION'),
                'bucket' => env('WASABI_BUCKET'),
            ],

        '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),
            'throw'                   => false,
        ]

    ],

    'links' => [
        public_path('storage') => storage_path('app/public'),
    ],

];

app.php

   /*
    |--------------------------------------------------------------------------
    | Application URL
    |--------------------------------------------------------------------------
    |
    | This URL is used by the console to properly generate URLs when using
    | the Artisan command line tool. You should set this to the root of
    | your application so that it is used when running Artisan tasks.
    |
    */

    'url'       => 'http://127.0.0.1:8000',

    'asset_url' => 'http://127.0.0.1:8000/public',

.env

APP_DEBUG=true
APP_URL=http://127.0.0.1:8000/

php artisan storage:link
ERROR The [C:Users....projectpublicstorage] link already exists.

2

Answers


  1. It seems the storage is already linked. I am not sure what folder do you have inside public folder, for example,

    If the folder structure is like public/storage/abc.png then the link will be something like this,

    http://127.0.0.1:8000/storage/abc.png
    

    check this resolves your issue, or please elaborate what you are trying and what you are getting.

    Thanks

    Login or Signup to reply.
  2. You need to run below command

    php artisan storage:link
    

    after that you can directly access the image or files

    Example: http://127.0.0.1:8000/abc.png
    

    enter image description here

    ref: https://laravel.com/docs/11.x/filesystem

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search