How to Get Size of Directory in MB Laravel?

How to Get Size of Directory in MB Laravel?

In this post we will give you information about How to Get Size of Directory in MB Laravel?. Hear we will give you detail about How to Get Size of Directory in MB Laravel?And how to use it also give you demo for it if it is necessary.

Mostly we require to calculate for uploaded directory size because we can see how much we size allocate in uploaded directory. If you have limited server then you always need to check how much size of data in my folder.

You can also get size of directory that way you can also display on your admin panel. Laravel provide File facade. File facade through we can get folder size in kb or mb or gb etc.

In bellow example i have

images directory in public folder. so we can get size for images folder like this way :

Example:

$file_size = 0;


foreach( File::allFiles(public_path('images')) as $file)

{

$file_size += $file->getSize();

}


$file_size = number_format($file_size / 1048576,2);

print_r($file_size.' MB');

Hope this code and post will helped you for implement How to Get Size of Directory in MB Laravel?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

3  +  4  =  

We accept paid advance and paid guest Posting on our Site : Contact US