How to get free space on server?

Posted by nikola, With 0 Comments, Category: PHP, Tags: ,

If you want to get info about free space on server, or in particular directory, execute next code in your browser - it will give you info about free space on server's directory defined in variable $dir:

$dir = '/var/www/htdocs/';
$space = round(disk_free_space($dir) / 1024 / 1024 / 1024);
echo ("Free space: " . $space . " GB");