Home > Backend Development > PHP Tutorial > How to get file size in php_PHP tutorial

How to get file size in php_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:36:46
Original
914 people have browsed it

Copy code The code is as follows:

static function convert($size) {
$unit=array('b',' kb','mb','gb','tb','pb');
                return @round($size/pow(1024,($i=floor(log($size,1024)))) ,2).' '.$unit[$i];
}


The following method can also be used

Copy code The code is as follows:


/**
 * Returns a human readable filesize
 */
function HumanReadableFilesize($size) {
$mod = 1024;
$units = explode(' ','B KB MB GB TB PB');
for ($i = 0; $size > $mod; $i++) {
$size /= $ mod;
}
return round($size, 2) . ' ' . $units[$i];
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/736851.htmlTechArticleCopy the code The code is as follows: static function convert($size) { $unit=array('b','kb ','mb','gb','tb','pb'); return @round($size/pow(1024,($i=floor(log($size,1024)))),2). ' '.$unit[$i]; }...
Related labels:
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 Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template