PHP Resumable Download Server
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.
Features
- 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.)
Known Issues
- 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.
BitBucket
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.
Download
Installation instructions is in the readme.txt file.
Download latest version from the BitBucket repository.
Comments
-
On 21.05.08 02:12 GMT Shamus said:
Hi. There is no settings.ini file in the package, as referenced in step 1 of your readme.txt file. Please advise how to access this file. -
On 27.05.08 18:08 GMT Thomas Thomassen said:
My apologies Shamus. The reference to "settings.ini" in the readme.txt is suppose to be "server.ini".
Thanks for pointing that out. -
On 12.02.09 10:34 GMT Thangaraj said:
Great script!
Worked well for me. I used the partial download feature into one of our file serving scripts.
Thank you :) -
On 12.02.09 17:26 GMT Thangaraj said:
Great script!
Worked well for me. I used the partial download feature into one of our file serving scripts.
Thank you :) -
On 13.03.09 07:21 GMT shabi said:
i want to find php server so i get it from this web. -
On 19.06.09 11:53 GMT Stuffs said:
line: 152
// workaround for IE filename bug with multiple periods / multiple dots in filename
// that adds square brackets to filename - eg. setup.abc.exe becomes setup[1].abc.exe
$iefilename = preg_replace('/./', '%2e', $basename, substr_count($basename, '.') - 1);
----------
$iefilename =
should be read
$basename =
Else your IE fix is not going to be passed once it it outside that section that fixes it. -
On 22.06.09 21:30 GMT Thomas Thomassen said:
Thanks Stuffs! -
On 02.10.09 21:20 GMT Neil said:
Just FYI -- if you attempt to do byte-range requests with this download server over HTTPS/SSL with a self-signed certificate using the iPhone, it will fail mysteriously with only a generic "This movie cannot be played" error on the iPhone. This took me a week to finally figure out.... -
On 03.10.09 18:25 GMT Thomas Thomassen said:
@Neil
hm. I've not dealt with HTTPS/SSL. Not sure why that doesn't work. You emphasize self-signed certificate, does it work with any other types? -
On 06.10.09 14:21 GMT Chris Gibbs said:
Hi Thomas, I hope you don't mind, but I've filed an improvement to the WordPress MU project that will use your logic to support byte-range downloads. You can see it here: [trac.mu.wordpress.org]
Also, I would like to say thank you for keeping your code open, it has saved me a lot of time and work! -
On 14.10.09 17:41 GMT Thomas Thomassen said:
Not a problem Chris. Glad it's of help. Thanks for posting back a link to where it's used. -
On 11.11.12 03:24 GMT Nguyen Thai Ha said:
That's Greate. Thanhks Thomas !
Archived Posts:
Subscribe to this Blog:
Labels:
- accessibility
- animation
- api
- background-image
- barcelona
- career
- changelog
- christmas
- code
- colour
- com
- css
- deardiary
- del
- desktopx
- distance
- documentation
- dom
- england
- events
- film
- fun
- gadget
- games
- gestures
- halloween
- html
- ie
- innerhtml
- ins
- javacript
- keyboard
- life
- list-style-image
- lists
- london
- modelmaking
- moving
- msn
- paintball
- performance
- php
- pingback
- pixar
- position
- printer
- product
- ruby
- scanner
- scheme
- scripting
- semantic
- server
- sidebar
- sketchup
- skype
- snow
- software
- speed
- split()
- test
- travel
- underground
- userinterface
- vertex
- vista
- voip
- w3c
- webdesign
- website
- whitespace