How to Get File Size from Path in Laravel?

Share Me
  •  
  •  
  •  
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share
How to Get File Size from Path in Laravel?

Hi Dev’s, In this tutorial,I will show you how to get file size from path in laravel 8 application. We can simply and easy get file size in laravel application.

Now in bellow example i will give you path of my images folder inside public folder and one image. That will give path as argument of size function:

Solution :-
/**
 * Show the application dashboard.
 *
 * @return \Illuminate\Contracts\Support\Renderable
 */
public function index(Request $request)
{
    $fileSize = \File::size(public_path('image/house2.jpeg'));

    dd($fileSize);
}

Output :-

26849 //size for 26,849 bytes

Read Also : Laravel Ajax Image Upload With Intervention Package

I hope it will help you. Also you can follow us on Facebook

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →