Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $file = "endereço/meu_arquivo.pdf";
- $mime_types = array(
- //mime do pdf
- 'pdf' => 'application/pdf',
- //mimes do Word
- 'doc' => 'application/msword',
- 'docm' => 'application/vnd.ms-word.document.macroenabled.12',
- 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
- 'dot' => 'application/msword',
- 'dotm' => 'application/vnd.ms-word.template.macroenabled.12',
- 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
- //Mimes do excel
- 'xl' => 'application/excel',
- 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12',
- 'xlf' => 'application/x-xliff+xml',
- 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12',
- 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12',
- 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
- 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12',
- 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
- );
- //Pega a extensão do arquivo
- $ext = pathinfo($file, PATHINFO_EXTENSION);
- //usa a extensão como chave para procurar o mime correto e envia ao navegador
- header('Content-type: ' . $mime_types[$ext]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement