000webhost provide 1.5 GB of free hosting space which is great for people who want to get started with their own website. But as all free hosting it has some other limitations like number of files on one account. To find out the number of file on your account 000webhost does not provide anything on their control panel. So we have to create a file counter to keep track of the number of files on 000webhost’s account.
A simple file counter can be created like.
<?php
function scan_dir($dirname) {
$count['Files'] = 0;
$count['Folders'] = 0;
$dir = opendir($dirname);
while (($file = readdir($dir)) !== false) {
if($file != "." && $file != "..") {
if(is_file($dirname."/".$file))
$count['Files']++;
if(is_dir($dirname."/".$file)) {
$count['Folders']++;
$counts = scan_dir($dirname."/".$file);
$count['Folders'] += $counts['Folders'];
$count['Files'] += $counts['Files'];
}
}
}
closedir($dir);
return $count;
}
$dirname = "./";
$count = scan_dir($dirname);
print_r ( $count );
?>
Create a text document and paste the above code into it and save it as “file.php” Upload this file in the root of your webhost’s directory and execute by going to http://yoursite.com/file.php and see the files count.
Comments
Post a Comment