Limit disk space allocation

I have a project management application . Anyone can sign up but as the space is limited, I need to limit the space for each user so they can't upload more than the allocated quota. How Can I allocate the fixed space for the created user?

How are you keeping track of what they have uploaded? If its in a database just include the sizes and when they upload something new you could just reject it if the new file will push them over quota. If you just have them in a directory per user then a quick scan over the directory should suffice.

How can you stop them uploading something that is too big to upload in the first place? Maybe something can be done in Javascript and or Flash. There are a few file uploaders available, maybe they could be modified to check the size of the file being uploaded before it is uploaded and pop up an alert if the new file will take you over quota. Much better than letting the user upload a file and then saying “Over quota, file deleted”.

However I am not an expert on Javascript so I could be talking out of my bum. Maybe someone more knowledgeable could chip in.

Much better than letting the user upload a file and then saying "Over quota > file deleted".

You'd have to check the file on server side too, as javascript alone cant guarantee that the file wont be uploaded anyway. To check on the serverside the whole file has to be uploaded first before you can check its size. Javascript should only be used for userfriendliness. For instance, if the files are big they will take a while to upload and then it might be a good idea to try and check it with javascript beforehand. If the files are small, you might as well do it all on the server side, as the user wont notice much difference anyway.

All of that being said, I belive your web site would have to be in the browsers "trusted zone" before you'd have access to read files with javascript anyway, so its probably not an option.

Sharagoz -- wrote:

Much better than letting the user upload a file and then saying "Over quota > file deleted".

You'd have to check the file on server side too, as javascript alone cant guarantee that the file wont be uploaded anyway. To check on the serverside the whole file has to be uploaded first before you can check its size. Javascript should only be used for userfriendliness. For instance, if the files are big they will take a while to upload and then it might be a good idea to try and check it with javascript beforehand. If the files are small, you might as well do it all on the server side, as the user wont notice much difference anyway.

All of that being said, I belive your web site would have to be in the browsers "trusted zone" before you'd have access to read files with javascript anyway, so its probably not an option.

JavaScript in a Web browser cannot touch the client's filesystem at all. I don't know if it has access to size information of a file that's in a file field.

Best,