2013-07-12 4 views

답변

1

순수 PHP 솔루션은 다음과 같이 (간체) 수 :

http://yourserver.com/download/... 
: 홈페이지 - 다시 같은 것으로 할 수있다

http://yourserver.com/download.php?file=... 

:

<?php 

$file = $_GET['file']; 
check_if_file_is_ok_for_download($file); 

header('Content-Type: ...'); 
header('Content-Length: ...'); 
header('Content-Dispostion: ...'); 
// more headers if necesarry ... 

// output the file 
readfile($file); 

// count the finished download 
database_add_finished_download($file); 

는 다음과 같은 다운로드 링크를 사용

+0

감사합니다!이 솔루션은 정말 간단하지만 파일을 전달하는 PHP는 많은 메모리를 확보합니다. 서버 솔루션에 대한 제안 사항이 있습니까? – dzubchik

+0

고 부하 환경에서> 5GB 파일을 제공하는 비디오 서버 서버에서이 기능을 사용했습니다. 메모리 문제 없음. 스크립트는 ** 다운로드하지 않은 ** 다운로드 한 파일의 파일 크기만큼의 메모리를 소비합니다. – hek2mgl

+0

정말, [doc] (http://php.net/manual/en/function.readfile.php)에 따르면이 함수를 사용하면 메모리 문제가 발생하지 않습니다. – dzubchik

관련 문제