Easy to find the size of a directory using php script
Just copy and paste the code to a file <somename>.php on your server or localhost
$totalsize=0;
function show_dir($dir, $pos=1){
global $totalsize;
if($pos == 1)
echo "<hr /><pre>";
$handle = @opendir($dir);
while ($file = @readdir ($handle)){
if (eregi("^\.{1,2}$",$file))
continue;
if(is_dir($dir.$file)){
echo "|- ".$pos."s <b>$file</b>\n";
show_dir("$dir.$file/", $pos+3);
}else{
$size=filesize($dir.$file);
echo "|- ".$pos."s $file ";
echo("$size <br />");
$totalsize=$totalsize+$size;
}
}
@closedir($handle);
if($pos == 2) echo "</pre><hr />";
return($totalsize);
}
//here customize your directory
//you can give any dirrectory without any subdirectory
//i have given c:/Program Files/xampp/htdocs/Ajax Test/
$totalsize = show_dir("c:/Program Files/xampp/htdocs/Ajax Test/");
echo($totalsize);
echo " Bytes";
Incoming search terms:
- php show directory size (2)
- print * in php program (2)
- php script directory size (1)
- php script show folder file size (1)
- php script show folder sizes (1)
- php script to display a size of a directory (1)
- check file size in a directory using PHP (1)
- php show folder and file size (1)
- search direktori dengan php (1)
- search in directory using php (1)
- to find size of folder using jquery (1)
- php display folders size (1)
- php code to find the size of a folder (1)
- how to find folder size using php script (1)
- checking directory size in php (1)
- directory size mb php code (1)
- display directory size php (1)
- display the size of a folder php (1)
- folder dir show in web page jquery php (1)
- folder size calcualtion using Jquery (1)
- folders & files size display in php (1)
- how to check folder size in php (1)
- how to display directory size php (1)
- how to file directory size php (1)
- view directory using php (1)
You will also be interested in ,
- Creating a simple class file using PHP
- Captcha using php
- Display mysql table using for loop in php
- PHP class simple tutorial
- MD5 Function and Unique ID in php
- Hit counter using php
- Fix Too many connections mysql_connect
- Date in title bar using php
- Count distinct records or values and display it using mysql and php
- Get textbox value from dropdown using ajax and php

As long as you change all the ” marks to the correct ascii character, this works a treat on both harddisk directories and on the web.
To view a web directory, change
$totalsize = show_dir(“c:/Program Files/xampp/htdocs/Ajax Test/”);
to:
$totalsize = show_dir(“http://website.com/directory/”);
To view the local directory where the script is being run, change it to:
$totalsize = show_dir(“./”);