Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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;
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #laravel #access #file #storage #path #alternative #symlink
ADD COMMENT
Topic
Name
7+8 =