Published in: PHP
|
|
|
URL: http://jonasjohn.de/snippets/php/dl-speed-limit.htm
This snippet shows you how to limit the download rate of a file download.
Expand |
Embed | Plain Text
// local file that should be send to the client $local_file = 'test-file.zip'; // filename that the user gets as default $download_file = 'your-download-name.zip'; // set the download rate limit (=> 20,5 kb/s) $download_rate = 20.5; // send headers // flush content // open file stream // send the current file part to the browser // flush the content to the browser // sleep one second } // close file stream else { }
Comments
Subscribe to comments
You need to login to post a comment.


I am writing code for file download with speed limitation as was described below. Using sleep in file data sending loop causes browser to hang - it waits for file but download don't starts. If I comment sleep statement - all works. What could be the problem? System: Debian squeeze 2.6.31.6, Apache 2.2.14-3, PHP 5.2.11