anyone has a good solution on how to limit directory's space. If a user uploads more than a maximum amount, he/she will be denied. Intead of having a file reading total bytes in that directory, is there any other to set it to a max size?
Thanks!
directory quota
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Not sure if it works on windows but if you're using *nix then make it a home dir (or subdir of one) for a user with limited quota.
If its not your server then I'd go with your first approach... use a recursive function to check out all the file sizes and give you the total file size.
Something like this but I'm completely blotto cos it's 2:16am and I'm at work soon so need some sleep so someone should check it over first.
If its not your server then I'd go with your first approach... use a recursive function to check out all the file sizes and give you the total file size.
Something like this but I'm completely blotto cos it's 2:16am and I'm at work soon so need some sleep so someone should check it over first.
Code: Select all
function size_recursive($path, $s=0) {
if (is_dir($path)) {
if ($path != '.' && $path !== '..') {
$h = opendir($path);
while ($f = readdir($h)) {
if (is_dir($path.'/'.$f) && $f != '.' && $f != '..') {
$s = size_recursive($path.'/'.$f, $s);
} else {
$s += filesize($path.'/'.$f);
} //End if
} //End while
closedir($h);
} //End if
} else {
$s += filesize($path);
} //End if
return $s;
} //End function
//Example
$dir = 'c:/webs';
echo size_recursive($dir); //Total size in bytes of c:/websthanks d11wtq,
I probably just go with the method you and Skara mentioned, that way the script can be used on any *nix hosting service, and its purpose is to provide members with some web space to upload things to. Thank you for your snippet too.
Here is a cup of coffe to keep your eyes wide open on the road to work:
[_]? <--- capuchino
..on second thought, 2am and going to work, I might let you have a big bowl of coffee - have you ever had one? haha \____/
I probably just go with the method you and Skara mentioned, that way the script can be used on any *nix hosting service, and its purpose is to provide members with some web space to upload things to. Thank you for your snippet too.
Here is a cup of coffe to keep your eyes wide open on the road to work:
[_]? <--- capuchino
As already mentionned, for EXT2 etc you want to read "man quota".
But if i'm not mistaken, on NTFS you can also apply quotas.. (http://www.microsoft.com/resources/docu ... o_lvms.asp)
But if i'm not mistaken, on NTFS you can also apply quotas.. (http://www.microsoft.com/resources/docu ... o_lvms.asp)