CancelImage Upload

How to calculate how much free disk space is left within a specified location using PHP

Disk space is one of those things most programmers rarely think about. Until the moment it is all used up that is! Lucky PHP has a function with the sole purpose of returning the amount of free disk space left within a specified location.

In the following example code we will determine the amount of free disk space left within the route folder. Note that the free amount will be returned in bytes, so you better have your mathematicians hat on to convert the returned value into Giga and Megabytes!


$dir = "/";

echo "The directory \"$dir\" has ".disk_free_space($dir)." bytes of free space!";


Want to leave a comment?

No problem. Just enter your email and password below.

register | home | reminder

myDesignTool Networking •