We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39678
    • 68 Posts
    hello,

    is their a function or something else to display the disk free space and total disk space of a the hosting?

    thanks
    tom
      • 37105
      • 194 Posts
      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
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        No, this would be a function of the hosting's control panel.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 37105
          • 194 Posts
          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
            • 39678
            • 68 Posts
            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