PHP xls,xlsx,ppt,pptx标头 [英] PHP xls, xlsx, ppt, pptx headers
问题描述
这是我的代码,我试图在其中发送对文档类型正确的标头定义.我想出了pdf,doc和docx的标题,但是我仍然需要知道Excel和Powerpoint文件的正确标题.
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.
任何帮助表示赞赏.
$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
application/vnd.ms-excel
.xlsx
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.ppt
application/vnd.ms-powerpoint
application/vnd.ms-powerpoint
.pptx
application/vnd.openxmlformats-officedocument.presentationml.presentation
application/vnd.openxmlformats-officedocument.presentationml.presentation
您列出的其中一项是错误的:
And one of those you have listed is wrong:
.docx
application/vnd.openxmlformats-officedocument.wordprocessingml.document
application/vnd.openxmlformats-officedocument.wordprocessingml.document
这篇关于PHP xls,xlsx,ppt,pptx标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!