working on it ...

Filters

Explore Public Snippets

Sort by

Found 1 snippet

    public by anndmill  1165  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");
    ?>

    List Complete ( 1 snippet total )

    Cannot find what you were looking for?
    Ask the Snip2Code Community

    • Public Snippets
    • Channels Snippets