Inside this article we will see the concept of How to get files information from directory in laravel 8. In laravel application we store public accessible files inside /public folder.
By this tutorial you will get the idea about finding file information from any directory inside laravel application. In a folder we store files of any type like image, pdf, doc etc.
File information like it’s name, size, extension etc. This tutorial will use laravel Filesystem concept to get file details. Tutorial will be super easy to understand and implement.
Learn More –
- Concept of Route Middleware in Laravel 8 Tutorial
- Concept of Route Model Binding in Laravel 8 with Example
- Concept of Trait in Laravel 8 Tutorial with Example
- Create Custom 404 Page in Laravel 8 | Page Not Found
Let’s get started.
Analyze Public Folder
Suppose in a laravel application we have few images into /public/images folder.
We can see 4 images available in images folder.
Let’s find the file information of these in laravel.
Next, we need to create a controller file.
$ php artisan make:controller FileController
It will create a file FileController.php at /app/Http/Controllers folder.
Open FileController.php and write this complete code into it.