2014-02-11 4 views
0

여기에 약간의 다운로드 스크립트 설정이 있는데 잘 작동합니다. 나는 응답 헤더가 문제의 범위를 좁히고 시간의 대부분 만 전송되고 어떤 일이 일어나지 않을 때 디스크에 이름을 제외하고 파일을 다운로드하지 말고 파일을 다운로드하라는 요청을 받는다. 'application/octet-stream'. 여기에 파일 정보는 때때로 전송되는 내가 나의 문제에 대해 명확하게하기 위해 PHP가 일관성없는 동작을 다운로드합니다.

header('Content-Description: File Transfer'); 
header('Content-Disposition: attachment; filename="'.$file->logical_name.'"'); 
header('Content-Type: "'.$mime.'"'); 
header("Content-Length: ".filesize($this->file)); 
header('Expires: 0'); 
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 
header('Cache-Control: no-store, no-cache, must-revalidate'); 
header('Pragma: no-cache'); 
readfile($this->file); 

을 보내고 헤더하고 그들이 해달라고 할 때 나는 때문에 그것을 전송되는 파일에 대한 정보를없는 내 문제를 얻을 이 '응용 프로그램/octet-stream을'이 일을 읽기 전에 모든 출력을 세척 미만 1백킬로바이트

답변

0

주위에 작은 파일로 발생 dosnt

UPDATE (디스크로)라는 이름의 weired로 다운로드되는 전자 파일은 문제를 해결합니다. 모든 헤더가 실제로 (()는 ReadFile을 사용하여 파일을 읽기) 플러시() 함수를 추가

header('Content-Description: File Transfer'); 
header('Content-Disposition: attachment; filename="'.$file->logical_name.'"'); 
header('Content-Type: "'.$mime.'"'); 
header('Content-Length:'.filesize($this->file)); 
header('Expires: 0'); 
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 
header('Cache-Control: no-store, no-cache, must-revalidate'); 
header('Pragma: no-cache'); 
flush(); 
readfile($this->file); 

문제를 해결 파일을 다운로드 tyring 전에 보내진 확인 키이었다 보인다. 내가 ob_start로 버퍼를 시작하지 않았다는 것을주의하라. ob_flush를 수행하지는 않았지만,이 경우에 그렇게했다.

관련 문제