note 76084 added to function.filesize
| From: | BIZARREdotBG | Date: | Fri, 29 Jun 2007 10:18:26 +0000 |
| Subject: | note 76084 added to function.filesize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128081@lists.php.net to get a copy of this message | ||
Here is a simple addition to the original example that i have made.
First of all i must mention that i need to list all files in a dir and i do know all files names.
Because the filenames contains an INT at the same place in every file's name i use $n++ to
generate the file names.
The code:
<?php
// outputs e.g. bits_01.jpg: 0.05 kb
//lets asign a value of 1 so we can start with file bits_01.jpg
$n = 1;
//the last file is bits_09.jpg so i call the WHILE until $n gets a value of 9
while ($n < 10) {
//using $n in each file's name
$filename = 'bits_0'.$n.'.jpg';
//getting the file size - from original example
$size = filesize($filename);
//while i don't wan't the result in bytes instead i divide by 1024 to print it out in kilo
bytes (if you need it in MB then divide it by 1048576
//at the same line we round the result to the fourth sign after the comma
$sizemb = round(($size/1024),4);
//printing the result
//filename : size MB and brake to print next on the next line
echo $filename . ': ' . $sizemb . ' kb<br />';
//now after i've printed the first file and it's size, we proceed to the next one
$n++;
}
?>
Hope it is useful to someone.
P.S
Please excuse my bad English :-)
----
Server IP: 195.149.248.161
Probable Submitter: 213.91.245.50
----
Manual Page -- http://www.php.net/manual/en/function.filesize.php
Edit -- https://master.php.net/note/edit/76084
Del: integrated -- https://master.php.net/note/delete/76084/integrated
Del: useless -- https://master.php.net/note/delete/76084/useless
Del: bad code -- https://master.php.net/note/delete/76084/bad+code
Del: spam -- https://master.php.net/note/delete/76084/spam
Del: non-english -- https://master.php.net/note/delete/76084/non-english
Del: in docs -- https://master.php.net/note/delete/76084/in+docs
Del: other reasons-- https://master.php.net/note/delete/76084
Reject -- https://master.php.net/note/reject/76084
Search -- https://master.php.net/manage/user-notes.php