Answers for "laravel - access file from storage path - alternative to symlink"

PHP
0

laravel - access file from storage path - alternative to symlink

Route::get('storage/{filename}', function ($filename)
{
    $path = storage_path('public/' . $filename);

    if (!File::exists($path)) {
        abort(404);
    }

    $file = File::get($path);
    $type = File::mimeType($path);

    $response = Response::make($file, 200);
    $response->header("Content-Type", $type);

    return $response;
});
Posted by: Guest on January-20-2022

Code answers related to "laravel - access file from storage path - alternative to symlink"

Browse Popular Code Answers by Language