|
-
Sep 18th, 2004, 09:06 AM
#1
Thread Starter
Lively Member
set folder size limit
hi
how can i give a limit for a folder size im my site
-
Sep 20th, 2004, 05:31 AM
#2
Frenzied Member
It can be done serverside, but if you're the only one uploading, just don't upload more than you want to? I not sure I got your question right.
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Sep 20th, 2004, 07:25 AM
#3
Thread Starter
Lively Member
hi
I added image upload to my site but i want to make the folder at max 10 MB
so how can do it
It can be done serverside
-
Sep 20th, 2004, 07:31 AM
#4
Well, in the script that handles uploads, you could calculate the current folder size and check if the addition of the new file will go over the limit. If so, reject the file.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 20th, 2004, 11:20 AM
#5
Thread Starter
Lively Member
ok
I need php code that do this
calculate the current folder size and check if the addition of the new file will go over the limit. If so, reject the file.
can you help me?
-
Sep 20th, 2004, 12:07 PM
#6
Frenzied Member
You could use a recersive function that use the filesize function.
http://www.php.net/manual/en/function.filesize.php
Dimitri over there posted this function:
Code:
function dir_size($dir) {
$totalsize=0;
if ($dirstream = @opendir($dir)) {
while (false !== ($filename = readdir($dirstream))) {
if ($filename!="." && $filename!="..")
{
if (is_file($dir."/".$filename))
$totalsize+=filesize($dir."/".$filename);
if (is_dir($dir."/".$filename))
$totalsize+=dir_size($dir."/".$filename);
}
}
}
closedir($dirstream);
return $totalsize;
}
I haven't tested it but I guess it will work.
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|