2013-06-07 2 views
0

PHP로 다운로드 할 텍스트 파일을 만들었지 만, 마지막에 숫자 1이 계속 들어 있습니다. 1111111111111111111111 버퍼를 플러시할지 여부를 결정합니다. 출력 자체가 좋습니다. 결국이 외의 쓰레기가 있습니다. 모든 단서?PHP - 다운로드 용 파일 생성

function exportMyOrders() { 
    $output = $this->getMyOutput(); 

    // Push the report. 
    $today = getdate(); 
    $today_str = $today['year'].'-'.$today['mon'].'-'.$today['mday']; 
    $export_file = 'MyFileName_'.$today_str.'.txt'; 
    header("Content-Description: File Transfer"); 
    header("Content-Disposition: attachment; filename=" . urlencode($export_file)); 
    header("Content-Type: application/force-download"); 
    header("Content-Type: application/octet-stream"); 
    header("Content-Type: application/download"); 
    header("Pragma: no-cache"); 
    header("Expires: 0"); 
    //  flush(); 

    print $output; 
    die(); 
} 
+0

$ 출력의 끝 부분이나 파일의 끝 부분에? –

+1

3 개의 Content-Type 헤더를 설정하는 것이 유용하다고는 생각하지 않습니다. 'getMyOutput'에 대한 코드를 추가 할 수 있습니까? – andrewsi

답변

-1

AHA! 찾았어요. 출력을 만드는 함수에서 나는 다음을 가졌습니다.

$output .= print($next_order); 

내가 왜 그렇게했는지 모릅니다. 간단한 그것을 수정 :

$output .= $next_order; 

DUH는!