Solved

Filesize for multiple files

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
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 count occurrences of each item in an array.

760 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

22 Experts available now in Live!

Get 1:1 Help Now