hello,
is their a function or something else to display the disk free space and total disk space of a the hosting?
thanks
tom
Create a snippet with this code
$freediskspace = disk_free_space(realpath('/')); // works on windows and linux
return $freediskspace;
Codeplaza Webdesign: for professional websites at low cost
-
☆ A M B ☆
- 24,524 Posts
No, this would be a function of the hosting's control panel.
And more readable
/**
* Convert bytes to human readable format
*
* @param integer bytes Size in bytes to convert
* @return string
*/
function bytesToSize($bytes, $precision = 2)
{
$kilobyte = 1024;
$megabyte = $kilobyte * 1024;
$gigabyte = $megabyte * 1024;
$terabyte = $gigabyte * 1024;
if (($bytes >= 0) && ($bytes < $kilobyte)) {
return $bytes . ' B';
} elseif (($bytes >= $kilobyte) && ($bytes < $megabyte)) {
return round($bytes / $kilobyte, $precision) . ' KB';
} elseif (($bytes >= $megabyte) && ($bytes < $gigabyte)) {
return round($bytes / $megabyte, $precision) . ' MB';
} elseif (($bytes >= $gigabyte) && ($bytes < $terabyte)) {
return round($bytes / $gigabyte, $precision) . ' GB';
} elseif ($bytes >= $terabyte) {
return round($bytes / $terabyte, $precision) . ' TB';
} else {
return $bytes . ' B';
}
}
$freediskspace = disk_free_space(realpath('/')); // works on windows and linux
return bytesToSize($freediskspace);
Codeplaza Webdesign: for professional websites at low cost
thanks for your help, but as Sotwell says, i think it is not possible with php
the function of donquicky shows me only the space free of the whole server, but not the account self