PHP calculates the size of a folder
Release: 2016-07-25 09:01:24
Original
870 people have browsed it
http://blog.1dnet.net/?post=839
-
//http://blog.1dnet.net
- 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";
- ?>
复制代码
|
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
-
2024-08-27 16:42:01
-
2024-08-27 16:40:02
-
2024-08-27 16:33:01
-
2024-08-27 16:32:21
-
2024-08-27 16:32:09
-
2024-08-27 16:31:17
-
2024-08-27 16:31:09
-
2024-08-27 16:30:51
-
2024-08-27 16:30:02
-
2024-08-27 16:29:01