簡體   English   中英

Windows LocalHost上的下載速度慢

[英]Slow Download Speed on Windows LocalHost

我在VDS上安裝了localhost(xammp,wampserver)。 當我嘗試使用PHP Curl和file_get_contents獲取文件時,下載速度非常低。 我可以在10分鍾內下載100mb的文件。 如果嘗試使用瀏覽器下載相同的文件,則持續時間僅為3秒。 可能是什么原因? 謝謝你的關注。

在特定的URL上下載內容是Internet上的慣例,尤其是由於越來越多地使用Amazon,Alexa,Digg等提供的Web服務和API。PHP的cURL庫通常帶有默認的共享托管配置,允許Web開發人員完成此任務。

你可以嘗試

/* gets the data from a URL */
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}

用法

$ returned_content = get_data(' http://davidwalsh.name '); //這樣的東西

另外,您可以遠程使用file_get_contents函數,但是許多主機不允許這樣做。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM