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

elo's avatar
Level 3

Images uploaded in storage not accessible

In a laravel 5.6 project, I created a symbolic link using php artisan symboli:link cammand which then created a storage directory in my public folder on my development server. Everything seems to work fine on dev server but after deploying on shared hosting, image upload works fine and I can see the image in appname/storage/app/public/images/photos but the file is not in public_html/storage/images/photos.

When I copied an uploaded file from appname/storage/app/public/images/photos to public_html/storage/images/photos, I was able to display the picture on the site as I wanted.

How can I fix this issue? This is how I am uploading the images

public function store(Request $request)
{
    $this->validate(request(), [
        'photo' => 'required|max:4000|mimes:jpeg'
    ]);

    /**
        * Retrieve uploaded photo
        * Define storage path
        * Get original file extension
        * Define filename to store photo & upload file
        */
    $file = $request->file('photo');
    $destinationPath = 'public/images/photos/';
    $filename = 'rayda_concept_photos_'.rand(1, 1000).'.'.$file->extension();

    if (Storage::putFileAs($destinationPath, $file, $filename)) {
        $photo = Photo::create([
            'photo' => $filename
        ]);

        Session::flash('success', 'You have successfully uploaded a photo.');

        return back();
    }

}

filesystem.config file looks like this (no change made)

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

    ],

html used for displaying the image

<div class="card">
         <img src="{{ URL::asset('storage/images/photos/'.$photo->photo) }}" alt="{{$photo->photo}}" class="card-img-top img-fluid">
</div>
0 likes
9 replies
andreich1980's avatar

you should run php artisan symboli:link at the shared hosing as well. it does not create a storage folder, it creates a link to /storage/app/public in your public_html folder.

elo's avatar
Level 3

@ANDREICH1980 - Is there a way I can create the symbolic link on shared hosting without ssh? Been waiting on the hosting support guys but no response yet.

andreich1980's avatar

@ELO - Try something like this. Add it to a temporary /test route.

symlink('/home/username/public_html/storage', '/home/username/public_html/storage/app/public');

use your path to the directories

JackL's avatar
JackL
Best Answer
Level 17

Here is a link to a video how to create a symbolic link without ssh. Starts around the 10:00 mark. link

1 like
elo's avatar
Level 3

@ANDREICH1980 - As suggested, I created the route for test and add this code to it then called it but got an error symlink(): No such file or directory

route::get('/test', function () {
    symlink('/home2/raydacon/public_html/storage', '/home2/raydacon/raydaconcept/public_html/storage/app/public');
});
Robstar's avatar

Symlinks rarely work on shared hosting. You'll need to ask your host to create the symlink for you. You should look at this an opportunity to get some decent hosting :)

elo's avatar
Level 3

@ROBSTAR - This particular client already purchased a domain name and the hosting with a preferred host so I had no input in that but I also learnt something new today on how symbolic links can be created without ssh on shared hosting.

elo's avatar
Level 3

@JACKL - Creating a php file in the public_html and attempting to access a route with the filename worked like magic. Everything worked fine after that. Basically it was something similar to what @andreich1980 suggested but without the need to create a route for it.

1 like
usmankhan7419@gmail.com's avatar

as I also got error and I fixed it by changing $this->photo->store('photo')

to

$this->photo->store('public')

as by the documentation of File Storage laravel we have

"make these files accessible from the web, you should create a symbolic link from public/storage to storage/app/public"

and in this way my issue got resolved.

Please or to participate in this conversation.