Solved

Filesize for multiple files

Posted on 2011-09-09
5
215 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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.  …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

930 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now