Link to home
Start Free TrialLog in
Avatar of Zado
ZadoFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Filesize for multiple files

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.
Avatar of Cong Minh Vo
Cong Minh Vo
Flag of Viet Nam image

use sum of filesize(filename) function
http://php.net/manual/en/function.filesize.php
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
Avatar of Zado

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Loganathan Natarajan
Loganathan Natarajan
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Zado

ASKER

Thanks.

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