.mp4 파일을 다운로드하려고합니다. (약 1.3GB 크기). PHP 파일에서 강제로 다운로드 중입니다.
<?php
$path = "video.mp4";
header('Accept-Ranges: bytes'); // For download resume
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename="'.basename($path).'"');
header('Content-Length: ' . filesize($path)); // File size
header('Content-Transfer-Encoding: binary'); // For Gecko browsers mainly
header('Content-Type: application/octet-stream');
header('Expires: 0');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($path)) . ' GMT');
header('Pragma: no-cache');
ob_clean();
flush();
readfile($path);
내가 내 PHP 파일을 열고, 파이어 폭스는 "저장하려면"메뉴 팝업 : 내가 사용하여 다음과 같은거야. 크기가 옳다. 다른 이름으로 저장을 눌러 내 바탕 화면으로 이동하십시오. 최종 다운로드 파일은 약 400MB (330, 463 및 440)의 임의 크기로 나열됩니다.
응답 헤더는 다음과 같습니다
Connection: Keep-Alive
Content-Disposition: attachment; filename="//www.frederikspang.dk/elevgallavideo.mp4"
Content-Length: 1422778850
Content-Type: video/mp4
Date: Sun, 30 Jun 2013 22:12:30 GMT
Keep-Alive: timeout=10, max=50
Pragma: public
Server: Apache
content-transfer-encoding: binary
실행 제한 시간에 맞춰 실행 중일 수 있습니다. 동일한 시간 후에 다운로드가 항상 중단됩니까? –
Resumable 파일 다운로드에는 이보다 훨씬 많은 코드가 필요합니다. 그래서 Accept-Ranges를 제거해야합니다. 참조 : http://stackoverflow.com/questions/157318/resumable-downloads-when-using-php-to-send-the-file –
실제로 출력 버퍼링을 사용하고 있습니까? 그렇지 않으면 readfile 명령이 클라이언트에 직접 데이터를 출력하므로 ob_clean() 및 flush()가 필요하지 않습니다. – dethtron5000