PHP xls, xlsx, ppt, pptx headers
Here is my code where I am trying to send a correct header depedning on a type of a document. I figured out the headers for pdf, doc and docx but I still need to know correct header for Excel and Powerpoint files.
Any help appreciated.
$document = urldecode($_GET['document']);
$extension = end(explode('.', $document));
$mimeType = '';
switch ($extension) {
case 'pdf':
$mimeType = 'pdf';
break;
case 'doc':
$mimeType = 'msword';
break;
case 'docx':
$mimeType = 'msword';
break;
case 'xls':
$mimeType = '';
break;
case 'xlsx':
$mimeType = '';
break;
case 'ppt':
$mimeType = '';
break;
case 'pptx':
$mimeType = '';
break;
}
header('Content-type: application/' . $mimeType);
.xls
application/vnd.ms-excel
.xlsx
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.ppt
application/vnd.ms-powerpoint
.pptx
application/vnd.openxmlformats-officedocument.presentationml.presentation
And one of those you have listed is wrong:
.docx
application/vnd.openxmlformats-officedocument.wordprocessingml.document
See http://www.w3schools.com/media/media_mimeref.asp .
xls is application/vnd.ms-excel
, ppt is application/vnd.ms-powerpoint
.
由于大多数请求的类型都是与Microsoft Office相关的,所以这个链接具有所有的办公室MIME类型(目前我发现的最重要的源代码):http://filext.com/faq/office_mime_types.php
链接地址: http://www.djcxy.com/p/45496.html上一篇: 为什么是哑剧