Your HostICan Community  


Go Back   Your HostICan Community > Programming & Design > PHP / MySQL Assistance

PHP / MySQL Assistance We understand. Not all of you are experienced programmers, but some of you are highly skilled at coding. So we've set aside this forum so you can ask questions, and provide answers to the most commonly asked PHP / MySQL issues.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-08-2009, 03:27 PM
bladgo bladgo is offline
Junior Member
 
Join Date: Mar 2009
Posts: 3
Default display size of a directory on my hosting through a web browser

How is possible using php code to get a recursive folder size? I want to have a few scripts to be able to watch the size of particular folders on my hosting through web browser.
Reply With Quote
  #2  
Old 10-08-2009, 03:55 PM
BigJON BigJON is offline
Member
 
Join Date: Jan 2009
Posts: 89
Default Re: display size of a directory on my hosting through a web browser

PHP Code:
<?php
function GetFolderSize($d ="." ) {
$h = @opendir($d);
if(
$h==0)return 0;
while (
$f=readdir($h)){
if ( 
$f!= "..") {
$sf+=filesize($nd=$d."/".$f);
if(
$f!="."&&is_dir($nd)){
$sf+=GetFolderSize ($nd);
}
}
}
closedir($h);
return 
$sf ;
}
?>
GetFolderSize - This function shows the size of the file. In example above, the script reads the directory and apply the function for an each file. Use these lines to see the result in the browser:
PHP Code:
<?php
echo " The Folder Size is : " GetFolderSize$path ) . " Bytes";
?>
Reply With Quote
Reply

Tags
browser, directory, display, hosting, size, web

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 03:58 PM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.

Copyright © 2003 - 2008 HostICan. All Rights Reserved.