Friday, February 18, 2011

List of files and filesize in directory using php

Date folder files are listed out same time file size also displayed using php simple script:

'<'?php date_default_timezone_set("Asia/Calcutta"); $today = date("Y-m-d"); $dir = '/var/www/jack/'.$today.'/'; if (is_dir($dir)) { if ($dh = opendir($dir)) { $i=1; while (($file = readdir($dh)) !== false) { if($file!="." && $file!="..") { echo $i++.".".$file." ( ". filesize($dir . $file) ." )'<'br/>";
}
}
closedir($dh);
}
}
?>

No comments:

Post a Comment