This is a discussion on Directory Size within the PHP Programming forums, part of the Web Development category; well i want to get the total size of a directory, ive managed to get this code HTML Code: to ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| well i want to get the total size of a directory, ive managed to get this code HTML Code: to display the file size of every file in the directory
[php]
PHP Code:
<?php
$dir = "../demo/themes/";
$tree = array();
$dirs = array(array($dir, &$tree));
for($i = 0; $i < count($dirs); ++$i)
{
$d = opendir($dirs[$i][0]);
$tier =& $dirs[$i][1];
while($file = readdir($d))
{
if ($file != '.' and $file != '..')
{
$path = $dirs[$i][0] . DIRECTORY_SEPARATOR . $file;
if (is_dir($path))
{
$tier[$file] = array();
$dirs[] = array($path, &$tier[$file]);
}
else
{
$size2 = filesize($path);
$size = array($size2);
print_r($size);
echo "<br>";
}
}
}
}[/php]
the only problem is adding all them together. my inital idea was to create a array that stores the file size in a new element then just create a loop that adds them all together. the only problem i have is every file size is stored in array element 0
HTML Code:
Array ( [0] => 0 )
Array ( [0] => 881 )
Array ( [0] => 97 )
Array ( [0] => 970 )
Array ( [0] => 1246 )
Array ( [0] => 0 )
Array ( [0] => 123 )
Array ( [0] => 1678 )
Array ( [0] => 1661 )
Array ( [0] => 2184 )
Array ( [0] => 8689 ) |
| Sponsored Links |
| |||
| MDS reports space used on your local and network drives. * Quickly identify where space is used. * Export results to HTML, Text and Excel. * Sort results by Size or Name jack _______________________________ fear of flying cowboy boots |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Actove Directory | Sundaram | VB.NET Programming | 1 | 02-25-2008 07:40 AM |
| size of object repository,size,object,repository,QTP | itbarota | Testing Tools | 4 | 08-17-2007 03:43 AM |
| How can I create a virtual directory (or map virtual directory) for my website in TFS | kingmaker | ASP and ASP.NET Programming | 1 | 07-27-2007 06:34 AM |
| how can we know the size of the object repository? | itbarota | Testing Tools | 1 | 07-27-2007 05:57 AM |
| Why aren't my frames the exact size I specified? | oxygen | HTML, CSS and Javascript Coding Techniques | 1 | 07-27-2007 03:50 AM |