Author Topic: Limit space available for useruploads  (Read 2647 times)

0 Members and 1 Guest are viewing this topic.

Offline gustav

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Limit space available for useruploads
« on: March 17, 2005, 08:35:50 AM »
I hope that has not been asked before..... could not find anything but limiting number of pics a user can upload.....
As the logics are simple, I am sure someone of you guys can do it with ease!? ;)
For example...
1) I want to limit the space a user can use for uploading his pics to 5 MB.... When the first file gets uploaded, the script checks if it already exceeds the allowed space (if allowed filesize bigger than 5 MB)..... If a second pic gets uploaded, the script first substracts the size of the picture that got already uploaded from the available space and then does the first check again... so, looks if the size of the new picture is smaller than the newly calculated available space. If so, the second pic gets stored, too.
Now, let us say these two pics have a total size of 4,6 MB... so, if a third picture should be uploaded now, with a size of 1 MB, the script performs the same tasks as above.... but as the size would now exceed the available space, the script refuses the upload....
This would work without a new database field

2) if new database field can be used..... :  pic 1 gets uploaded.... filesize then gets substracted from available space stored in database. New space then gets written back to database. On next upload, same taks are redone.... Guess this version has some advantages from the first version!? ... for example... faster statistics as recalculating space for all users may take some time if there are enough of them!?

Can anyone do that? ...or is it to hard?