Reputation: 25
can anyone help me to get each file size individually from a local directory ?.
$files = scandir('soft');
foreach($files as $file) {
echo $file . "<br />";
}
Upvotes: 2
Views: 3257
Reputation: 1534
From here
$files = scandir('soft');
foreach($files as $file) {
if (!in_array($file,array(".","..")))
{
echo $file . "<br />";
echo filesize('soft/'.$file) . ' bytes';
}
}
Just need to keep in mind that scandir gets only the filenames in that dir, and not the relative path to it. that's why you need to use 'soft/'.$file
and not $file
Upvotes: 3
Reputation: 511
<?
$files = scandir('.');
foreach($files as $file) {
echo filesize($file) . " bytes<br>";
}
?>
Upvotes: 1