사용자에게 다운로드 파일을 보내고 싶지만 HTTP 헤더가 잘못 전송됩니다. Content-type: application/octet-stream
이 전송 될 것으로 예상되지만 여전히 Content-Type: text/html; charset=utf-8
이 표시됩니다. 누군가 내 실수를 저에게 지적 할 수 있습니까? TYPO3 7.6.22TYPO3 extbase : 다운로드에 대한 올바른 응답 헤더를 보내십시오.
TypoScript :
page_1505214798 = PAGE
page_1505214798 {
typeNum = 1505214798
config {
contentObjectExceptionHandler = 0
xhtml_cleaning = 0
admPanel = 0
disableAllHeaderCode = 1
additionalHeaders {
}
debug = 0
}
10 = USER_INT
10 {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
vendorName = DIX
extensionName = Dixeventmanager
pluginName = Meeting
controller = Event
action = download
switchableControllerActions {
Event {
1 = download
}
}
}
}
Extbase 컨트롤러 액션
public function downloadAction() {
// $fn = ...
$result = file_get_contents(PATH_site . $fn);
$this->response->setHeader('Content-type', 'application/octet-stream');
$this->response->setHeader('Content-Disposition', 'attachment; filename="'. basename($fn) .'"');
return $result;
}
파일 이름과 내용 - 처리 헤더가 바로 컨텐츠 형은 어딘가 덮어 제대로 전송됩니다.
콘텐츠 유형이 수정되었습니다. 그러나 그것은 다양 할 수 있습니다. (doc, pdf, ...) - OK, 테스트 코드에서 하드 코딩 된 것이 명확하지 않습니다. –