Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sanjayacloud's avatar

Cannot access storage files from public folder (403 Forbidden error)

Hello everyone ,

I have hosted one of my sites on digital ocean with Plesk.

Now I am trying to access my uploaded (Using Laravel-medialibrary ) images from the public folder it's getting

Forbidden You don't have permission to access this resource.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

I have set permission to storage path as 777 and also I have run php artisan storage:link successfully.

This happened for my new uploading files. This is work what I have already uploaded files.

Anyone can help me no this?

This is my filesystem config file

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Default Filesystem Disk
    |--------------------------------------------------------------------------
    |
    | Here you may specify the default filesystem disk that should be used
    | by the framework. The "local" disk, as well as a variety of cloud
    | based disks are available to your application. Just store away!
    |
    */

    'default' => 'local',

    /*
    |--------------------------------------------------------------------------
    | Default Cloud Filesystem Disk
    |--------------------------------------------------------------------------
    |
    | Many applications store files both locally and in the cloud. For this
    | reason, you may specify a default "cloud" driver here. This driver
    | will be bound as the Cloud disk implementation in the container.
    |
    */

    'cloud' => 's3',

    /*
    |--------------------------------------------------------------------------
    | Filesystem Disks
    |--------------------------------------------------------------------------
    |
    | Here you may configure as many filesystem "disks" as you wish, and you
    | may even configure multiple disks of the same driver. Defaults have
    | been setup for each driver as an example of the required options.
    |
    | Supported Drivers: "local", "ftp", "s3", "rackspace"
    |
    */

    '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_KEY'),
            'secret' => env('AWS_SECRET'),
            'region' => env('AWS_REGION'),
            'bucket' => env('AWS_BUCKET'),
        ],
        'media' => [
            'driver' => 'local',
            'root'   => public_path('media'),
        ],

    ],

];


0 likes
11 replies
sr57's avatar

Have a look to your server logs, it's a pb of link or rights and the should give you the clue.

sanjayacloud's avatar

I have checked it. But the is no error in the error log.

sanjayacloud's avatar

@sr57 I sow below error in the server error log

Got error 'PHP message: PHP Warning: symlink(): Permission denied in

UsmanBasharmal's avatar

The solution is to create a symlink with a relative path from the project root-like

ln -s ../storage/app/public public/storage

This should solve the permissions problem.

Edit: I just noticed there is a built-in option to achieve the exact same thing: php artisan storage:link --relative

2 likes
sanjayacloud's avatar

I have run php artisan storage:link --relative

It said The "--relative" option does not exist.

Please note I am using laravel 6

1 like
UsmanBasharmal's avatar

Can you post your view where you want to display your image It must be for example like below:

   <image src="{{asset('/storage/images/products/'.$product->image)}}">
sanjayacloud's avatar

@usmanbasharmal Here is my view

``

 <div class="col-md-10 offset-1">
            <div class="card">
                <div class="card-header">
                    Existing Categories
                </div>

                <div class="card-body">
                    <div class="table-responsive">
                        <table class=" table table-bordered table-striped table-hover datatable-User">
                            <thead>
                            <tr>
                                <th width="10"></th>
                                <th>#</th>
                                <th class="text-center">Name</th>
                                <th class="text-center">Image</th>
                                <th class="text-center">Description</th>
                                <th class="text-center">Status</th>
                                <th class="text-center">Action</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($categories as $key => $category)
                                <tr data-entry-id="{{ $category->id }}">
                                    <td></td>
                                    <td>{{ $category->id ?? '' }}</td>
                                    <td>{{ $category->name ?? '' }}</td>
                                    <td>

                                        <img width="100" src="{{asset($category->getFirstMedia('category')->getUrl('thumb'))}}" alt="Thumbnail">
                                    </td>
                                    <td>
                                        {{$category->description}}
                                    </td>
                                    <td class="text-center align-middle">
                                        @if($category->status==0)
                                        <span class="badge badge-primary p-2">Active</span>
                                        @else
                                            <span class="badge badge-danger p-2">Inactive</span>
                                         @endif
                                    </td>
                                    <td class="text-center align-middle">
                                        
                                        <div class="btn-group">
                                            <a class="btn btn-xs btn-info" href="{{ url('admin/category/edit/'. $category->id) }}">Edit</a>
                                            <a class="btn btn-xs btn-primary" href="{{ url('admin/category/sub-category/'. $category->id) }}">Sub Categories</a>
                                        </div>

                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>

``

UsmanBasharmal's avatar

Where do you want to show the image or where do you want to access the image show us that view

sr57's avatar

symlink(): Permission denied in

Assuming you use apache, check

-1- Apache conf for FollowSymLinks, if needed share apache2.conf and your vhost conf

-2- ls -la /var/www/... for all the directories concern by your link

-2.1- owner of apache process

deanira's avatar

have you find a way to fix this issue yet? I/m facing the same error

markopolo404's avatar

El problema esta al momento de ejecutar el comando dentro del servidor:

php artisan storage:link

ya que lo estamos ejecutando como root y al intentar acceder al recurso nos devolverá un error 403 (prohibido). Por tanto tendremos que cambiar el grupo:propietario dentro de la carpeta "public" donde esta ubucado el enlace simbólico:

chown -h user storage

fuente :: "virtumedia.wordpress.com/2019/06/26/publicar-proyecto-laravel/"

2 likes

Please or to participate in this conversation.