Last active
February 11, 2018 05:34
-
-
Save biobii/fa5cf6f9ab3da317afc107fa18142939 to your computer and use it in GitHub Desktop.
Alternative to load image from storage folder in Laravel.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Route::get('/media/img/{filename}', function($filename) { | |
$path = storage_path('app/public/' . $filename); | |
if (! \File::exists($path)) | |
abort(404); | |
$file = \File::get($path); | |
$type = \File::mimeType($path); | |
return response($file, 200)->header('Content-Type', $type); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment