PHP 8.5.0 Alpha 1 available for testing

Voting

: three plus four?
(Example: nine)

The Note You're Voting On

jason dot whitehead dot tas at gmail dot com
17 years ago
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;
}
?>

<< Back to user notes page

To Top