note 88531 added to features.file-upload
| From: | info at levaravel dot com | Date: | Wed, 28 Jan 2009 08:10:54 +0000 |
| Subject: | note 88531 added to features.file-upload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-149878@lists.php.net to get a copy of this message | ||
Here is a function I wrote for file uploads, which returns the filesize in a standard format:
<?php
//
function display_filesize($filesize){
if(is_numeric($filesize)){
$decr = 1024; $step = 0;
$ext =
array('Byte','KB','MB','GB','TB','PB');
while(($filesize / $decr) > 0.9){
$filesize = $filesize / $decr;
$step++;
}
return round($filesize,2).' '.$ext[$step];
} else {
return 'NaN';
}
}
// Usage:
// display_filesize(int number);
echo display_filesize(1263541);
// writes: 1.21 MB
echo display_filesize(1000000000);
// writes: 0.93 GB
echo display_filesize('stringvalue');
// writes: NaN
?>
----
Server IP: 69.147.83.197
Probable Submitter: 80.218.130.245
----
Manual Page -- http://www.php.net/manual/en/features.file-upload.php
Edit -- https://master.php.net/note/edit/88531
Del: integrated -- https://master.php.net/note/delete/88531/integrated
Del: useless -- https://master.php.net/note/delete/88531/useless
Del: bad code -- https://master.php.net/note/delete/88531/bad+code
Del: spam -- https://master.php.net/note/delete/88531/spam
Del: non-english -- https://master.php.net/note/delete/88531/non-english
Del: in docs -- https://master.php.net/note/delete/88531/in+docs
Del: other reasons-- https://master.php.net/note/delete/88531
Reject -- https://master.php.net/note/reject/88531
Search -- https://master.php.net/manage/user-notes.php