Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@flxxyz
Last active August 28, 2018 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flxxyz/22b204f33cfff8451ff46819a7b52894 to your computer and use it in GitHub Desktop.
Save flxxyz/22b204f33cfff8451ff46819a7b52894 to your computer and use it in GitHub Desktop.
读取大于2GB以上的文件
<?php
function get_safe_filesize($file)
{
$size = filesize($file);
if ($size <= 0) {
if (!(strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')) {
$size = trim(`stat -c%s $file`);
} else {
$fsobj = new COM("Scripting.FileSystemObject");
$f = $fsobj->GetFile($file);
$size = $f->Size;
}
}
return $size;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment