Level 16
Please show the following details so that anyone can understand.
- Your folder structure
- Error message
- Do you have a storage link to of storage folder to public folder or you are trying to access app/storage folder @cd4success
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am trying to update profile picture on a small laravel app but server returns 500 SERVER ERROR due to wrong directory structure. I have done some googling but most answers were 6, 5, 4, 3 and 2 years old. I'm using laravel 8. Here's my controller....
Thanks
public function updateAvatar()
{
// dd(request('avatar'));
$theUser = Auth::user();
request()->validate([
'avatar' => 'image|max:1000'
]);
// File upload
if (request()->hasFile('avatar')){
$path = request()->file('avatar')->storeAs('uploads', $request->file('avatar'));
$profileImage = Image::make(public_path('storage/' . $path))->fit(40,40);
// On the server: I have public_html/storage
$profileImage->save();
}
else{
$path = $theUser->avatar;
}
$theUser->update([
'avatar' => $path,
]);
request()->session()->flash(
'message', 'Your avatar was successfully updated.'
);
return redirect()->back();
}
Please or to participate in this conversation.