The download system should be used by many people. It is a very simple PHP application. However, when talking about PHP speed-limit download, it is estimated that some people are confused. In fact, this is also very simple. Below is a simple PHP download function combined with a limited speed to provide a piece of code. I hope it will be helpful for beginners: local file $ local_file
The download system should be used by many people. It is a very simple PHP application. However, when talking about PHP speed-limit download, it is estimated that some people are confused. In fact, this is also very simple. Below is a simple PHP download function combined with a limited speed to provide a piece of code. I hope it will be helpful for beginners: // local file $ local_file =
The download system should be used by many people. It is a very simple PHP application. However, when talking about PHP speed-limit download, it is estimated that some people are confused. In fact, this is also very simple. Below is a simple PHP download function combined with a limited speed to provide a piece of code. I hope it will be helpful to beginners:
// Local file $ local_file = 'test-file.zip '; // download is the default name $ download_file = 'your-download-name.zip'; // The download speed is limited to 5kb/s $ download_rate = 20.5; // check whether the file exists and ensure that the file is valid if (file_exists ($ local_file) & is_file ($ local_file) {// send the header ID header ('cache-control: private '); header ('content-Type: application/octet-stream'); header ('content-Length :'. filesize ($ local_file); header ('content-Disposition: filename = '. $ down Load_file); // refresh the output buffer flush (); // open the file $ file = fopen ($ local_file, "r"); while (! Feof ($ file) {// send the file print fread ($ file, round ($ download_rate * 1024); // buffer to the browser flush (); // pause 1 second execution sleep (1);} // close the file stream fclose ($ file);} else {die ('error: file --'. $ local_file. 'does not exist! ');}
Reprinted Please note: IT passers-by» PHP: how to limit the file download speed