Results 1 to 6 of 6

Thread: set folder size limit

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    106

    set folder size limit

    hi
    how can i give a limit for a folder size im my site

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    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.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    106
    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

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    106
    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?

  6. #6
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    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
  •  



Click Here to Expand Forum to Full Width