I am trying to create a simple file hosting script. I'm in the process of learning PHP myself, thus facing some difficulties..
The idea is to have each user's account to have their own bandwidth allocation (for downloading).
I'm not sure how this is done. I've done some searching, but I cannot find my answer. As far as I know there are two ways to do it,
- Find out the file size downloaded, make an assumption that the file should be completed, add it to bandwidth used.
The problem with this is if the file has been partially downloaded, it would provide inaccurate result.
- Find out the bytes transfered.
I've no idea how this is done... Buffering?
A good example of what I'm trying to do is something like Rapidshare. They have a really accurate method of calculating how much bandwidth was used.
Please enlighten me with some possible methods to do this.