Saturday, June 10, 2017

Sample Get file fany format Size Php

php script how to get file size

this file tric will read all file name
exe, mp4, mkv, mp3, zip

lets try mp3 and zip

look all working any file can be format in size mb
all working ok enjoyyy
<?php
function d_filesize($bytes, $decimals = 2) {
    $size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
    $factor = floor((strlen($bytes) - 1) / 3);
    return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor];
}

?>

CChange On m/adele.mp3 to your file name

<?php
echo d_filesize(filesize('m/adele.mp3'));
?>