Web Analytics Made Easy -
StatCounter Allocating space limits to directories - CodingForum

Announcement

Collapse
No announcement yet.

Allocating space limits to directories

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Allocating space limits to directories

    Is there a php method whereby I can create a directory and define a limit to the amount of space it consumes? As in, if I wanted to grant someone 10Mb of space on my account, how could this be automatically enforced?
    Llamasery Enlightened Internet Strategies
    "Psychics will lead dogs to your body." --Alleged fortune cookie message

  • #2
    only way is to only allow uploads by a PHP script - you can check the space, and either let the upload happen, or not!

    You can upload more than one file at a time too so it doesn't become restrictive

    Jee
    Jeewhizz - MySQL Moderator
    http://www.sitehq.co.uk
    PHP and MySQL Hosting

    Comment


    • #3
      Or, if you wanted to get even less restrictive... you could setup a directory only for that person to upload to, and use the file functions to read the files in the drirectory and count their sizes. add them all up and if they are more than 10 Megs... he cant upload.

      To start you off in that direction, you could use readdir() and filesize() in a loop.

      -Scott
      I think its right anyway.

      Comment


      • #4
        Okay, so what if the directory contains something to automatically increase its size through a web interface, like a blog, news content or FAQ manager, or even a forum? What would be the best way to apply a readdir() and filesize() loop to this scenario?
        Llamasery Enlightened Internet Strategies
        "Psychics will lead dogs to your body." --Alleged fortune cookie message

        Comment


        • #5
          disk_total_space (string directory)

          would return the bytes used for a directory.

          You could run up a cron job (daily) that meanders quickly through
          the list of named dirs and tests the byte usage, mailing you when
          one of them goes above 10meg.

          Fiddling about with ftp permissions (ie blocking an account that
          went over the ten) would be a tad harder to say the least.

          See http://www.php.net/manual/en/functio...otal-space.php
          for scriptlets that scan sub directories too.
          ضkii - formerly pootergeist
          teckis - take your time and it'll save you time.

          Comment


          • #6
            Thanks guys. Still digesting this, though at least I have a little more to go on now. Capping the directory size would have to be automatic rather than an emailed advisory. That's a good link though, Okii. I appreciate it.
            Llamasery Enlightened Internet Strategies
            "Psychics will lead dogs to your body." --Alleged fortune cookie message

            Comment

            Working...
            X