/ Published in: PHP

Getting files, folders, file count, folder count in a directory with php and writing them to a web page
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php $folderCount = $fileCount = 0; //. means current directory //if you wanna a learn a folders inside use opendir('path') if ($entry != "." && $entry != "..") { echo "Folder => " . $entry . "<br>"; $folderCount++; } else { echo "File => " . $entry . "<br>"; $fileCount++; } } } echo "<br>==============<br>"; echo "Total Folder Count : " . $folderCount . "<br>"; echo "Total File Count : " . $fileCount; } ?>
Comments
