anndmill
anndmill
Reputation Top 10%
anndmill
1 Snippet  (529th place)
Published
1 Channel
Created
1 Channel
Following
30 points  (1686th place)
Reputation
Junior Code Generator
Junior Publisher
Junior Trend Maker
Junior Popular Coder
Junior Autobiographer
Serious Autobiographer
Junior Famous Coder

Recent Snippets See all snippets by anndmill

public by anndmill  1168  0  6  0

Размер файла

<?php
// Enter here the actual content of the snippet.            
function getFilesize($file,$digits = 2) {
       if (is_file($file)) {
               $filePath = $file;
               if (!realpath($filePath)) {
                       $filePath = $_SERVER["DOCUMENT_ROOT"].$filePath;
       }
           $fileSize = filesize($filePath);
               $sizes = array("TB","GB","MB","KB","B");
               $total = count($sizes);
               while ($total-- && $fileSize > 1024) {
                       $fileSize /= 1024;
                       }
               return round($fileSize, $digits)." ".$sizes[$total];
       }
       return false;
}

echo getFilesize("file_name.ext");
?>
;