1073741824) { $size = round($size / 1073741824, 3) . 'GB'; } else if ($size > 1048576) { $size = round($size / 1048576, 2) . 'MB'; } else if ($size > 1024) { $size = round($size / 1024, 1) . 'KB'; } else { $size = $size . 'B'; } return $size; } /** * 获取文件夹体积 * * 使用Linux命令 * * 返回byte */ function FunGetDirSizeDu($path) { $cmd = sprintf("du -s '%s' | awk '{print $1}'", $path); $result = FunShellExec($cmd); $result = (int)trim($result) * 1024; return $result; } /** * 获取文件夹下的文件列表 * * 文件名 * 文件体积 * 最后修改时间 */ function FunGetDirFileList($path) { $filename = scandir($path); $fileArray = []; foreach ($filename as $key => $value) { if ($value == '.' || $value == '..' || is_dir($path . '/' . $value)) { continue; } array_push($fileArray, [ 'fileName' => $value, 'fileSize' => FunFormatSize(filesize($path . '/' . $value)), 'fileEditTime' => date('Y-m-d H:i:s', (int)filemtime($path . '/' . $value)) ]); } return $fileArray; }