tags:

views:

15

answers:

1

Hi

I am developing a file hosting site, where users can upload files to thier own folder. This folder can only have a quota of 100mb. I would like to implement a sytem whereby if a user tries tp upload a file to their folder which is already full to 100mb and will exeed their quota, the system will not allow it and display a message to the user.

Any ideas

Thanks

R

A: 

Most modern filesystems on most modern operating systems implement some kind of quota support. If you can't use those because to the operating system all the files are owned by just one user then you're going to need to re-implement this functionality.

This means either keeping track of file sizes when they're uploaded, e.g. a row in a database table in which case the question "how much are they already using?" can be answered with one query. Alternatively you could work this out every time someone tries to upload a file, by finding all files they own (presumably from a DB table?) and calling stat() or similar to query the size of each file.

Once you know how much they are already using the POST request or whatever method you're using to do the uploads will tell you the size of the incoming upload.

Be careful with size though - file size is often not the same as size on disk. Which is more important?

awoodland