Get File Size From Storage And Public Path In Laravel

Many times we need file size in Laravel to check uploaded files or something else. But many of us don't know how to get file size in Laravel. So I am here to discuss the way of getting file size in the Laravel application. I will show you how to get file size from the public path and storage path.

So in this Laravel get file size from path tutorial, you will learn how to get file size from URL in Laravel and also Laravel get file size from storage. I will share the source code of these two above conditions. It will work Laravel 5 to 8 versions. 

Laravel get file size from storage link example:

public function index()
{
  $fileSize = Storage::size('public/user/profile-pic.jpg');;
  dd($fileSize);
}

 

Laravel get file size from public path example:

public function index()
{
   $fileSize = File::size(public_path('images/user/profile.jpg'));
   dd($fileSize);
}

 

 Read also: Laravel Delete Image or File From Public or Storage Folder

 

Hope this Laravel get file size from URL tutorial can help you.

 

#laravel