Solved

Filesize for multiple files

Posted on 2011-09-09
5
219 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses four methods for overlaying images in a container on a web page
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

739 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