Download file from storage in Laravel

In this article we are going to discuss how you can view or download files from the storage. If you want to upload some files to storage you can view this tutorial

Routes

You can add the following code to your routes\web.php file

Action in controller

You have the getFile action in your UploadController. So you can add the following code to it

You get the file from the storage by giving the file name and get the response with correct content type

You have the view action also. You can add the following code to it

You get the image files from the public folder and extract the name of these files and you pass them to your view

View

Finally you can create a view display.blade.php in resources\view folder