1👍
My solution is create a api route to show image. For example.
api.php
Route::get('profile/{fileName}', 'ProfileController@showImage');
ProfileController.php
class ProfileController {
...
public function showImage($fileName)
{
$path = public_path("/images/{$fileName}");
if (!\File::exists($path)) {
return response()->json(['message' => 'Image not found.'], 404);
}
$file = \File::get($path);
$type = \File::mimeType($path);
$response = \Response::make($file, 200);
$response->header("Content-Type", $type);
return $response;
}
}
And you image src will be /api/profile/{imageName}
. This is my solution.
- [Vuejs]-Duplicate values showing everytime navigating to component
- [Vuejs]-How to detect response in VueJS?
Source:stackexchange.com