Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jun 2002
    Location
    Portland, Oregon
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 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
    Regular Coder
    Join Date
    May 2002
    Location
    London, England
    Posts
    369
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    New to the CF scene
    Join Date
    Jul 2002
    Location
    Cedar Lake, IN
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    New Coder
    Join Date
    Jun 2002
    Location
    Portland, Oregon
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #6
    New Coder
    Join Date
    Jun 2002
    Location
    Portland, Oregon
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •