cms icon indicating copy to clipboard operation
cms copied to clipboard

How to get path from uploaded image?

Open kaitoqueiroz opened this issue 7 years ago • 1 comments

image

This is a fresh install with no changes.

Why I had error 404 in all uploaded images?

kaitoqueiroz avatar Apr 07 '18 14:04 kaitoqueiroz

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.

michallesniak avatar Apr 09 '18 07:04 michallesniak