In PHP, we can use the disk_total_space
function to get the total space available.
This function will not work on remote files.
disk_total_space(string $directory): float|false
The function needs a directory
or a partition
as a mandatory parameter.
The function will return a floating number that represents the total space of the specified directory. Otherwise, it will return false
.
In this example, we will return the size of root directory.
<?php$ds = disk_total_space("/home");echo $ds;?>
The size returned is in bytes.