urum에서 server로 재개 가능한 파일을 다운로드하려면 PHP 스크립트가 필요합니다. 다운로드를 시작한 다음 스냅 (30 초 -5 분)하면 전체 파일을 완료 할 때까지 계속할 수 있습니다.큰 파일 청크를 PHP curl로 청크로 다운로드하십시오.
Perl의 비슷한 항목이 있습니다. http://curl.haxx.se/programs/download.txt이지만 PHP에서 처리하고 싶습니다. 펄을 모르겠습니다.
청크를 다운로드하려면 CURLOPT_RANGE
을 사용하고 서버에 파일에 추가하려면 fopen($fileName, "a")
을 사용하는 것이 좋을 것 같습니다.
여기 내 시도입니다 :
<?php
function run()
{
while(1)
{
get_chunk($_SESSION['url'], $_SESSION['filename']);
sleep(5);
flush();
}
}
function get_chunk($url, $fileName)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if (file_exists($fileName)) {
$from = filesize($fileName);
curl_setopt($ch, CURLOPT_RANGE, $from . "-");//maybe "-".$from+1000 for 1MB chunks
}
$fp = fopen($fileName, "a");
if (!$fp) {
exit;
}
curl_setopt($ch, CURLOPT_FILE, $fp);
$result = curl_exec($ch);
curl_close($ch);
fclose($fp);
}
?>
도움이 될 것입니다. http://stackoverflow.com/questions/2032924/how-to-partially-download-a-remote-file-with-curl – kpotehin