Php calculates the size of a file ,. Php calculates the size of a file. this example describes how php calculates the size of a file. Share it with you for your reference. The details are as follows: phpfunctiondirSize ($ directoty php calculates the size of a file,
This example describes how php calculates the size of a file. Share it with you for your reference. The details are as follows:
<?php function dirSize($directoty){ $dir_size=0; if($dir_handle=@opendir($directoty)) { while($filename=readdir($dir_handle)){ $subFile=$directoty.DIRECTORY_SEPARATOR.$filename; if($filename=='.'||$filename=='..'){ continue; }elseif (is_dir($subFile)) { $dir_size+=dirSize($subFile); }elseif (is_file($subFile)){ $dir_size+=filesize($subFile); } } closedir($dir_handle); } return ($dir_size); } $dir_size=dirSize("xym"); echo round($dir_size/pow(1024,1),2)."KB";?>
I hope this article will help you with php programming.
Example: php calculates the size of a file. Share it with you for your reference. Details: php function dirSize ($ directoty...