Answers for "php get file size in mb"

PHP
2

php get size of file

$fileSizeInBytes=filesize("/path/to/myfile.txt");
Posted by: Guest on October-22-2019
1

php file size in mb

public function calc_file_size($bytes) {
  if ($bytes >= 1073741824) {
    $bytes = ceil($bytes / 1073741824) . ' GB';

  } else if ($bytes >= 1048576) {
    $bytes = ceil($bytes / 1048576) . ' MB';

  } else if ($bytes >= 1024) {
    $bytes = ceil($bytes / 1024) . ' KB';

  } else if ($bytes > 1) {
    $bytes = $bytes . ' bytes';

  } else if ($bytes == 1) {
    $bytes = $bytes . ' byte';

  } else {
    $bytes = '0 byte';
  }
Posted by: Guest on October-12-2021

Browse Popular Code Answers by Language