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

rvsky's avatar
Level 1

Cannot see files in laravel on shared hosting

Hi! I have a problem. My laravel doesn't see images on shared hosting.

I have public folder in ~/domains/DOMAIN/public_html/APP and rest of files in ~/domains/DOMAIN/FILES.

My files are uploading to ~/domains/DOMAIN/FILES/storage/app/public/uploads/avatars

but in app I can't see this. I display it like: avatar

can you help me what to do?

0 likes
6 replies
RamjithAp's avatar

You must save your avatar files in public accessible folder like

~/domains/DOMAIN/public_html/APP/uploads/avatars
rvsky's avatar
Level 1

Can you help me with this? How to do it?

RamjithAp's avatar

Basically, the images which you wanted to show on your website should be stored after your domain name like yourdomain.com/images/avatars/11.jpg. So when you saving avatar save it into public folder because your domain name is pointed at your public_html/APP so you must save into that directory.

Or show me your file saving codes will help you.

rvsky's avatar
Level 1

That's the file

public function addAvatar(Request $request) { $this->validate($request, [ 'file' => 'required', ]);

    $user = $this->model->getUserById(Auth::user()->id);

    $file = $request->file('file')->store('/public/uploads/avatars');

    $filename = $request->file('file')->hashName();
    
    $extension = pathinfo($file, PATHINFO_EXTENSION);
    
    if($extension == 'png' OR $extension == 'jpg' OR $extension == 'jpeg'){

        $file = UserData::avatar($request, $filename, $user->id);

        return view('user.settings', compact('user')); 
    }
    else
    {
        $file = unlink($request->file('file'));

        return view('user.settings.files', compact('user'))->with('message', 'nope');
    }
}
RamjithAp's avatar

Change this line

$file = $request->file('file')->store(public_path() . '/uploads/avatars');
rvsky's avatar
Level 1

nothing changes. Cannot see image again

Please or to participate in this conversation.