This stores the file in the display_profile as avatars/filename.jpg.
Since I have multiple versions of the files for displaying around the views I am using prefixes like follow
thumb_filename.jpg
small_filename.jpg
large_filename.jpg
I will need to do a lot of string replace to insert the prefix in place to show the right version of the images. Is there any way I can save just the filename in the database instead of the full path?
If not what's the best way to show my files in the view?
Why not separating the file upload with the update:
// upload the file:
request()->display_profile->storeAs('avatars', $name,'public');
// save just the filename
$user->update([
'display_profile' => $name
]);
or getClientOriginalName() should also give you just the name of the file: