다음 PHP 스 니펫이 내부 500 오류를 일으키고 있으며 하나 이상의 헤더라고 생각됩니다. 오류보고를 활성화했지만 아무 것도보고하지 않습니다. 누군가 문제가 무엇인지 알 수 있습니까? 감사.PHP 헤더 함수로 내부 500 오류가 발생했습니다.
$file = CLIENTFOLDERS.$_GET['download'];
$fileSize = filesize($file);
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$type = finfo_file($finfo, $file);
finfo_close($finfo);
header("Cache-Control: private");
header("Content-Type: ".$type);
header("Content-Length: ".$fileSize);
header("Content-Disposition: attachment; filename=".basename($file));
readfile($file);
exit();
는 이상하게도, 파일이 다운로드되고 난 다시 응답 헤더를 얻을 :
Cache-Control:private
Connection:Keep-Alive
Content-Disposition:attachment; filename=CPS Letterhead form.doc
Content-Length:4
Content-Type:application/msword
Date:Mon, 10 Feb 2014 20:21:00 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=5, max=100
Pragma:no-cache
Server:Apache/2.4.7 (Win32) PHP/5.5.6
X-Powered-By:PHP/5.5.6
을하지만 MS Word 및 Excel 문서가 손상됩니다. PDF 및 텍스트 파일이 잘로드됩니다. 이미지 파일을 확인하지 않았습니다.
대부분의 가능성이없는 헤더를, $의 type' 아무 것도 반환하지 않은 '경우가있을 수 있다고 생각. 서버 로그를 점검하십시오. – Cfreak
'var_dump ($ type)'? – Hast
PHP 버전 5.3.0 이상? –