我有這裏的代碼,但我想限制用戶可以下載的速度,我將如何實現這個代碼;限制下載速度與PHP
header("Content-type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize("uploads/$filename"));
header("Content-disposition: attachment; filename=\"$origname");
readfile("uploads/$filename");
謝謝!
這是我試過的;
$download_rate = 100;
$ origname = get_file_name($ file [0]);
header("Content-type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize("uploads/$filename"));
header("Content-disposition: attachment; filename=\'$origname'");
$local_file = "uploads/$origname";
//同花順內容 flush();
// open file stream
$file = fopen($local_file, "r");
while (!feof($file)) {
// send the current file part to the browser
print fread($file, round($download_rate * 1024));
// flush the content to the browser
flush();
// sleep one second
sleep(1);
}
// close file stream
fclose($file);
爲什麼不工作?
是啊我已經閱讀過這篇文章,但是我真的需要一種方法來整合它,因爲我已經嘗試過並失敗了! – HarryBeasant 2012-01-28 23:49:29
好吧,你嘗試了什麼?它是如何失敗的?這似乎是一個很好的起點,所以不要要求所有人重做你已經完成的任務。 – Hamish 2012-01-28 23:52:23
它會給出錯誤,下載速度更快還是失敗? – Mike 2012-01-28 23:52:24