|
[تحسين] الحصول على عدد الملفات فى مجلد ما
الحصول على عدد جميع الملفات فى مجلد ما وكل ما يحتويه من مجلدات فرعية function filecount($FolderPath) {
$filescount = 0;
// Open the directory
$dir = opendir($FolderPath);
// if the directory doesn't exist return 0
if (!$dir){return 0;}
// Read the directory and get the files
while (($file = readdir($dir)) !== false) {
if ($file[0] == '.'){ continue; }
//if '.' it is a sub folder and call the function recursively
if (is_dir($FolderPath.$file)){
// Call the function if it is a folder type
$filescount += filecount($FolderPath.$file.DIRECTORY_SEPARATOR);
}
else {
// Increment the File Count.
$filescount++;
}
}
// close the directory
closedir($dir);
return $filescount;
}
//add slash at the end of your page
$FolderPath='/usr/local/apache/htdocs/test/';
$filecount= filecount($FolderPath);
print "Your Total Files : ".$filecount;
|
الموقع الآن فى الفترة التجريبية وهذا الجزء غير كامل وجارى العمل عليه، للراغبين في المساعدة برجاء التقدم

