note 80959 modified in function.filesize by danbrown
| From: | danbrown@php.net | Date: | Sun, 18 Jan 2009 18:02:46 +0000 |
| Subject: | note 80959 modified in function.filesize by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-149398@lists.php.net to get a copy of this message | ||
I have created a handy function, using parts of code from kaspernj at gmail dot com and md2perpe at
gmail dot com, which should get file sizes > 4GB on Windows, Linux and Mac (at least).
<?php
function getSize($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 = $file->Size;
}
return $size;
}
?>
--was--
I have created a handy function, using parts of code from kaspernj at gmail dot com and md2perpe at
gmail dot com, which should get file sizes > 4GB on Windows, Linux and Mac (at least).
function getSize($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 = $file->Size;
}
return $size;
}
http://php.net/manual/en/function.filesize.php