readfile()을 사용하여 큰 파일 (1.3GB)을 다운로드하는 스크립트가 있습니다.ModX Evo : PHP readfile() 스 니펫?
그냥 스크립트로 .php 페이지를 만들면 정상적으로 작동하지만 스 니펫에 같은 스크립트를 배치하고 페이지에 배치하면 아무 일도 일어나지 않습니다.
ModX가 다운로드를 차단하는 이유는 무엇입니까? 어떤 조언이라도 대단히 감사 할 것입니다!
편집 코드 :
$file = $_SERVER['DOCUMENT_ROOT']."/movie.mov";
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
};
'header()'가 호출되기 전에'ob_clean();'이 오지 않아야합니까? – Niloct
@Niloct 일 수도 있지만 위의 내용은 PHP 설명서 – MeltingDog
의 예제입니다. Modx 코드 단편은 [출력] (http://rtfm.modx.com/display/revolution20/Snippets#Snippets-SimpleExample) 정보 만 반환 할 수 있습니다. '데이터. 그'flush()'는 범인일지도 모른다. – Niloct