如何使用PHP从web上的某个地方将大文件下载到web服务器?

如何使用PHP从web上的某个地方将大文件下载到web服务器?,php,download,Php,Download,如何使用PHP从web上的某个地方将大文件下载到web服务器?另外,为了实现这一点,服务器上应该允许什么?谢谢。用这个。PHP必须支持curl,显然,您需要一个可写的文件系统。这能做得好吗 <?php ini_set(max_execution_time, 0); $the_link = $_GET['url']; $ch = curl_init($the_link); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($

如何使用PHP从web上的某个地方将大文件下载到web服务器?另外,为了实现这一点,服务器上应该允许什么?谢谢。

用这个。PHP必须支持curl,显然,您需要一个可写的文件系统。

这能做得好吗

<?php
ini_set(max_execution_time, 0);

$the_link = $_GET['url'];

$ch = curl_init($the_link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT  5.1; .NET CLR 1.1.4322;)");
curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/cookies.txt');
$the_file = curl_exec($ch);
curl_close($ch);

$hdl = fopen("file", 'w');  
fwrite($hdl, $the_file);
fclose($hdl);
?>

php.ini中不需要更改某些内容吗?