简体   繁体   English

Windows LocalHost上的下载速度慢

[英]Slow Download Speed on Windows LocalHost

I installed localhost (xammp, wampserver) on a VDS. 我在VDS上安装了localhost(xammp,wampserver)。 When I try to get a file using PHP Curl and file_get_contents, the download speed is very low. 当我尝试使用PHP Curl和file_get_contents获取文件时,下载速度非常低。 I can download a 100mb file in 10 minutes. 我可以在10分钟内下载100mb的文件。 If I try to download the same file with a browser, the duration is only 3 seconds. 如果尝试使用浏览器下载相同的文件,则持续时间仅为3秒。 What can be the reason? 可能是什么原因? Thanks for your interest. 谢谢你的关注。

Downloading content at a specific URL is common practice on the internet, especially due to increased usage of web services and APIs offered by Amazon, Alexa, Digg, etc. PHP's cURL library, which often comes with default shared hosting configurations, allows web developers to complete this task. 在特定的URL上下载内容是Internet上的惯例,尤其是由于越来越多地使用Amazon,Alexa,Digg等提供的Web服务和API。PHP的cURL库通常带有默认的共享托管配置,允许Web开发人员完成此任务。

u can try 你可以尝试

/* 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;
}

The Usage 用法

$returned_content = get_data(' http://davidwalsh.name '); $ returned_content = get_data(' http://davidwalsh.name '); //something like this //这样的东西

Alternatively, you can use the file_get_contents function remotely, but many hosts don't allow this. 另外,您可以远程使用file_get_contents函数,但是许多主机不允许这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM