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

kvnkrft's avatar

Avatar working locally, but not on Forge / Digital Ocean... linking issue?

My avatar upload is working locally, and it looks like the upload on Forge is working as well, but I'm not able to access the avatar images on the server - locally no problem.

Files are being uploaded to ~/dev.site.com/storage/app/public/avatars I can see the link in the ~/dev.site.com/public directory:

lrwxrwxrwx 1 forge forge   46 Jan  2 20:30 storage -> /home/forge/dev.site.com/storage/app/public

I ran the php artisan storage:link command on the forge server, which I'm sure created that link.

Any ideas why can't access the images like I can locally?

0 likes
7 replies
ejdelmonico's avatar

Look at the nginx logs to see why the image is not found. Also, how are you accessing the image? You may be in need of checking that a beginning forward slash is in the path.

kvnkrft's avatar

In my blade template I'm accessing the avatar like this:

<img src="{{ $user->avatar() }}" class="mr-2" style="width: 40px; height: 40px;">

And the code behind that is:

    public function avatar(){
     
        if(! $this->avatar_path) {
            return asset('images/avatars/default.jpg');
        }

        return asset($this->avatar_path);
    }

I am just not sure why it would work in my local environment, but not up on Forge/DigitalOcean.

This is the final code on the server:

<img src="http://dev.site.com/avatars/fDOfm66s7wHxGAJqcacyM9MlEVqpGJdlLB5LYpyc.jpeg" class="mr-2" style="width: 40px; height: 40px;">

And this is what is works locally:

<img src="http://site.test/avatars/40mAMR2PsEbkvO8FGfzvyCETkmdtEo9SJwPtf8Ex.jpeg" class="mr-2" style="width: 40px; height: 40px;">
kvnkrft's avatar

I'm still fighting with this darn thing.

Snapey's avatar

according to your symlink you should have storage in the path

so asset() is giving you the wrong result?

kvnkrft's avatar

Hey @Snapey I don't think it's the wrong result - it works locally in my valet environment. So I'm thinking the linking isn't working right.

kvnkrft's avatar
forge@mysite-dev:~/dev.mysite.com/public$ ls -l
total 28
drwxrwxr-x 2 forge forge 4096 Jan  2 22:14 css
-rw-rw-r-- 1 forge forge    0 Jan  2 05:05 favicon.ico
drwxrwxr-x 3 forge forge 4096 Jan  2 05:05 fonts
drwxrwxr-x 3 forge forge 4096 Jan  2 22:14 images
-rw-rw-r-- 1 forge forge 1823 Jan  2 05:05 index.php
drwxrwxr-x 2 forge forge 4096 Jan  2 05:05 js
-rw-rw-r-- 1 forge forge   70 Jan  2 05:05 mix-manifest.json
-rw-rw-r-- 1 forge forge   24 Jan  2 05:05 robots.txt
lrwxrwxrwx 1 forge forge   46 Jan  2 20:30 storage -> /home/forge/dev.mysite.com/storage/app/public


forge@mysite-dev:~/dev.mysite.com/storage/app/public/avatars$ ls -l
total 332
-rw-r--r-- 1 forge forge 66395 Jan  2 20:24 alJoobTq5kupM9AwyiuWzparYvaHYJljcM0t7gs7.jpeg
-rw-r--r-- 1 forge forge 66395 Jan  2 20:31 fDOfm66s7wHxGAJqcacyM9MlEVqpGJdlLB5LYpyc.jpeg
-rw-r--r-- 1 forge forge 58009 Jan  4 00:07 FYkIuOEcDdqZYDO1Z1SMSFDNxZxcuB0A95Tt7SOK.jpeg
-rw-r--r-- 1 forge forge 66395 Jan  3 23:36 gbGHuNv3bOHGBvVIXyXXAU8RyXgtGjseNTlwOjqf.jpeg
-rw-r--r-- 1 forge forge 66395 Jan  4 00:03 JsHlRBofIA8ZliLExnYb9J1TAF2SR89E5cnq93xK.jpeg
Snapey's avatar

You say this works locally

<img src="http://site.test/avatars/40mAMR2PsEbkvO8FGfzvyCETkmdtEo9SJwPtf8Ex.jpeg" class="mr-2" style="width: 40px; height: 40px;">

but the files are not in the /avatars folder they are in the /storage/avatars folder

My guess would be that you have another symbolic link on local, or the one that is there is different to what artisan creates.

Your accessor in the model perhaps ought to be

return asset('/storage/' . $this->avatar_path);

Please or to participate in this conversation.