cms
cms copied to clipboard
How to get path from uploaded image?

This is a fresh install with no changes.
Why I had error 404 in all uploaded images?
This issue is connected with the problem, that the images are uploaded by default to storage directory. My solution to this problem is to set in the .env file:
UPLOAD_FOLDER=public/files
then add a new controller with the following function:
public function getUserAvatar($slug)
{
return response()->file(public_path('files/user/'.$slug));
}
finally add to your routes:
Route::get('/image/original/user/{slug}', AvatarController@getUserAvatar')->where('slug', '(.*)??');
Where 'AvatarController' is the name of the controller with 'getUserAvatar' method.