<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_59154"> <div class="blockcode"> <div id="code_EK9"><ol> <li>// local file that should be send to the client</li> <li>$local_file = 'test-file.zip';</li> <li> <li>// filename that the user gets as default</li> <li>$download_file = 'your-download-name.zip';</li> <li> <li>// set the download rate limit (=> 20,5 kb/s)</li> <li>$download_rate = 20.5;</li> <li> <li>if(file_exists($local_file) && is_file($local_file)) {</li> <li> <li> // send headers</li> <li> header('Cache-control: private');</li> <li> header('Content-Type: application/octet-stream');</li> <li> header('Content-Length: '.filesize($local_file));</li> <li> header('Content-Disposition: filename='.$download_file);</li> <li> <li> // flush content</li> <li> flush();</li> <li> <li> // open file stream</li> <li> $file = fopen($local_file, "r");</li> <li> <li> while (!feof($file)) {</li> <li> <li> // send the current file part to the browser</li> <li> print fread($file, round($download_rate * 1024));</li> <li> <li> // flush the content to the browser</li> <li> flush();</li> <li> <li> // sleep one second</li> <li> sleep(1);</li> <li> }</li> <li> <li> // close file stream</li> <li> fclose($file);</li> <li> <li>}</li> <li>else {</li> <li> die('Error: The file '.$local_file.' does not exist!');</li> <li>}</li> </ol></div> <em onclick="copycode($('code_EK9'));">复制代码</em> </div> <br> </td></tr></table> <div class="ptg mbm mtn"> 다운로드 속도, PHP</div> <div id="comment_59154" class="cm"> </div> <div id="post_rate_div_59154"></div> <br><br>