save file in folder Laravel

> Handle function to upload object file into storage folder Laravel framework.

$file = $request->file->getClientOriginalName();

$filename = pathinfo($file, PATHINFO_FILENAME);
$extension = pathinfo($file, PATHINFO_EXTENSION);

$path = '/storage/'.strtolower(Str::random(24)).'.'.$extension;
Storage::disk('public')->put($path, file_get_contents($request->file));

> Running php artisan storage:link to create a symlink.

php artisan storage:link

> Create custom Route in web.php as below:

Route::get('/storage/{filename}', function ($filename)

    $path = storage_path('app/public/storage/' . $filename);

    if (!File::exists($path)) {

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

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

    return $response;

> Here is structuring folder in Laravel project where file stored.

> You can access link as

You need to login to do this manipulation!