I wanted to add a download section to my site, but at the same time keep statistics of the files downloaded. So made a little PHP script to act as a download server.
This little script became a little larger when I added support for partial file downloads. I noticed that many comments in the PHP manual and other sources described the method wrong. For instance, many of them announced to accept multiple byte ranges while that was not the fact. And they also tended to not handle the requested byte range according to the HTTP 1.1 specifications.
Now, I'm never pretending this is a complete implementation or free for issues. But it should work very well and I've tried to make it behave to the specifications.
- Serves files from a file repository.
- Makes sure no files outside the repository is served.
- Lists files if a directory is requested.
- Supports partial file request allowing users to pause or accelerate downloads.
- Logging function to keep statistic over the file downloads. (Needs configuring to work.)
- Files larger than 2GB might give unexpected results on platforms that use 32-bit integers. This is because it might affect the calculation of filesizes.
21 June 2011: I have uploaded the project at BitBucket. It is the recommended way to obtain the project. Now you can send back your patches and improvements.
Installation instructions is in the readme.txt file.
Download latest version from the BitBucket repository.
Subscribe to this Blog: