我有下載網頁下面的PHP代碼文件直接到我的Web服務器:如何在php中限制file_put_contents的速度?
function fileDownload()
{
$url = $_POST['downloadlink'];
$filename = $_POST['filename'];
$dir = "downloads/";
$filepath = $dir . $filename;
file_put_contents($filepath, fopen($url, 'r'));
}
以上PHP函數可以很好地用於下載文件小於128 MB,但是,當文件大小超過128 MB,然後交通擁擠加載在我的服務器上創建,我的服務器暫時不可用,並中止所有連接。所以,我的文件下載被中止。我在考慮是否有任何方法來限制file_put_contents
函數的速率,這樣即使我下載的文件大於128 MB,我的服務器也能正常工作。
http://stackoverflow.com/questions/1603281/file-get-contents-and-file-put-contents-with-large-files – brandelizer
上面的鏈接並沒有給出如何限制速度的解決方案'file_put_contents'功能.... – user3752033
我知道,但也許你的服務器崩潰的原因... – brandelizer