Fw: [PHP] calculating kilobytes
| From: | Kevin Stone | Date: | Fri, 14 Feb 2003 20:40:12 +0000 |
| Subject: | Fw: [PHP] calculating kilobytes | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-135600@lists.php.net to get a copy of this message | ||
Joe, you might try something like this instead of a slow PHP function. I
based it off of a user example on the PHP site. This is tested and I use it
often for various purposes. I think it may be ideal for you becuase it is
extremely fast. Requires Linux though I'm certain there's an equivilant
command in Windows.
-------------------------------
$dir="/path/to/home/directory/";
$out =
find $dir -depth -type f;
$files = explode("\n", $out);
$numfiles = count($files);
for ($i=0; $i<$numfiles; $i++)
{
$filelist .= $files[$i]."<br>";
if (false != ($size = @filesize($files[$i])));
{
$totalfilesize += $size;
}
}
echo $numfiles." files<br>";
echo $totalfilesize." kilobytes total<br>";
echo $filelist;
--------------------------------
Let me know how that works for you.
- Kevin
----- Original Message -----
From: "joe" <liberache@hot.ee>
To: <php-general@lists.php.net>
Sent: Friday, February 14, 2003 12:17 PM
Subject: [PHP] calculating kilobytes
> hi
> first of all i think this is a great community here :)
>
> now to the point...
> i need a script. it should work on safe mode php so it should be as simple
> as possible.
> it should calculate all the file sizes in the directory that it is in and
in
> the subdirectories also (only 1 level subdirectories). it should echo the
> total size of the uploaded files.
> then it should take the filesize and substract it from 25 megabytes. that
is
> the limit on this server. then it should echo the result (the maximum
number
> of kilobytes that can still fit on this account).
> unfortunately i have insuffitient knowlege to do it miself.
> i just want to thank anyone who can help me.
> if you want to send it to my email then its liberache@hot.ee . or you can
> just write it here.
>
> thank you :)
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>