Check Total Space and Available Free Space in the Hosting Web Server

Even if some hosting providers offers unlimited web space for your website. There may be some fair usage policy to restrict the use of full resource and to limit the excess usage in order to maintain the server load.

If you want to check the hard disk capacity of your server including the total space of the disk and the available free space in the server. Just create a php file in your server, for eg : disk-info.php and add the following code in it.

$diskSpace = disk_total_space("/");
$diskSpaceGB = formatSizeUnits($diskSpace);
echo 'Total Disk Space : ' . $diskSpaceGB;
echo '
-------------------------------------
'; $freeDisk = disk_free_space("."); $diskFreeSpaceGB = formatSizeUnits($freeDisk); echo 'Total Free Space : ' . $diskFreeSpaceGB ; function formatSizeUnits($bytes) { if ($bytes >= 1073741824) { $bytes = number_format($bytes / 1073741824, 2) . ' GB'; } elseif ($bytes >= 1048576) { $bytes = number_format($bytes / 1048576, 2) . ' MB'; } elseif ($bytes >= 1024) { $bytes = number_format($bytes / 1024, 2) . ' KB'; } elseif ($bytes > 1) { $bytes = $bytes . ' bytes'; } elseif ($bytes == 1) { $bytes = $bytes . ' byte'; } else { $bytes = '0 bytes'; } return $bytes; }

Run the file in your browser eg : http://yourdomain.com/disk-info.php

You can view the total space and free space in your hosted disk in the server.

Leave a Comment