Solved

Filesize for multiple files

Posted on 2011-09-09
5
217 Views
Last Modified: 2012-08-13
Hi,

I need simple script to check size of few files, my variables are $f1, $f2, $f3, $f4, how to count total size of those files? Obviously I need to use filesize function, but how?

Thanks for any help.
0
Comment
Question by:Zado
5 Comments
 
LVL 15

Expert Comment

by:Minh Võ Công
ID: 36509269
use sum of filesize(filename) function
http://php.net/manual/en/function.filesize.php
0
 
LVL 7

Expert Comment

by:boon86
ID: 36509291
try this:
<?php
$filename1 = 'somefile1.txt';
$filename2 = 'somefile2.txt';
$filename3 = 'somefile3.txt';
$filename4 = 'somefile4.txt';

$f1 = filesize($filename1) . 'bytes';
$f2 = filesize($filename2) . 'bytes';
$f3 = filesize($filename3) . 'bytes';
$f4 = filesize($filename4) . 'bytes';

?>

hope that help
0
 
LVL 8

Author Comment

by:Zado
ID: 36509518
I found solution:

$total= (filesize($f8))+(filesize($f8b))+(filesize($f8c))+(filesize($f8d));

Open in new window

I tried this earlier, but I made mistake with round function, I've done this:
$round = round((filesize($inattsize)/1024/1024), 2)."MB"; instead this:
$round = round(($inattsize/1024/1024), 2)."MB";

Open in new window


Thanks for your help.
0
 
LVL 36

Accepted Solution

by:
Loganathan Natarajan earned 250 total points
ID: 36509528
some thing like this,

<?php
$f1 = filesize("test1.txt");
$f2 = filesize("test2.txt");
$f3 = filesize("test3.txt");
$f4 = filesize("test4.txt");

$tot = $f1+$f2+$f3$f4;

echo "Total Size = ".$tot;

?>

Open in new window

0
 
LVL 8

Author Comment

by:Zado
ID: 36509543
Thanks.

Correction for my last comment:
There should be $total instead $inattsize;
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question