Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP xls, xlsx, ppt, pptx headers

Tags:

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); 
like image 494
Richard Knop Avatar asked Jul 23 '10 12:07

Richard Knop


People also ask

What is Mimetype for XLSX?

application/x-xls. application/vnd. openxmlformats-officedocument. spreadsheetml. sheet (xlsx)

What is the full form of XLSX?

A file with the . xlsx file extension is a Microsoft Excel Open XML Spreadsheet (XLSX) file created by Microsoft Excel.


1 Answers

.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

like image 197
Mark Baker Avatar answered Oct 27 '22 00:10

Mark Baker