note 88077 modified in function.filesize by danbrown
| From: | danbrown@php.net | Date: | Fri, 09 Jan 2009 01:02:50 +0000 |
| Subject: | note 88077 modified in function.filesize by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-148974@lists.php.net to get a copy of this message | ||
<?php
### File list with file names and sizes
get_size('your_dir');
function get_size($path)
{
$count=0;
if(!is_dir($path)) return filesize($path);
if ($handle = opendir($path)) {
$size = 0;
while (false !== ($file = readdir($handle))) {
if($file!='.' && $file!='..') {$count++;
$size = get_size($path.'/'.$file); // Do not use $size +=...
$sizemb = ($size / 1024)/1024;
$sizemb = round($sizemb,2);
$sizegb = (($size / 1024)/1024)/1024;
$sizegb = round($sizegb,2);
echo "  <b>$eil_nr</b>. <a
href=your_dir/$file>$file</a> [";
if( $size >'1073741824') {echo "$sizegb GB";}else {echo "$sizemb
MB";}
echo"]<br />";
}
}
closedir($handle);
return $size;
}
}
?>
--was--
<?
### File list with file names and sizes
get_size('your_dir');
function get_size($path)
{
$count=0;
if(!is_dir($path)) return filesize($path);
if ($handle = opendir($path)) {
$size = 0;
while (false !== ($file = readdir($handle))) {
if($file!='.' && $file!='..') {$count++;
$size = get_size($path.'/'.$file); // Do not use $size +=...
$sizemb = ($size / 1024)/1024;
$sizemb = round($sizemb,2);
$sizegb = (($size / 1024)/1024)/1024;
$sizegb = round($sizegb,2);
echo "  <b>$eil_nr</b>. <a
href=your_dir/$file>$file</a> [";
if( $size >'1073741824') {echo "$sizegb GB";}else {echo "$sizemb
MB";}
echo"]<br />";
}
}
closedir($handle);
return $size;
}
}
?>
http://php.net/manual/en/function.filesize.php