Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. $file = "endereço/meu_arquivo.pdf";
  2.  
  3. $mime_types = array(
  4. //mime do pdf
  5. 'pdf' => 'application/pdf',
  6.  
  7. //mimes do Word
  8. 'doc' => 'application/msword',
  9. 'docm' => 'application/vnd.ms-word.document.macroenabled.12',
  10. 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  11. 'dot' => 'application/msword',
  12. 'dotm' => 'application/vnd.ms-word.template.macroenabled.12',
  13. 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
  14.  
  15. //Mimes do excel
  16. 'xl' => 'application/excel',
  17. 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12',
  18. 'xlf' => 'application/x-xliff+xml',
  19. 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12',
  20. 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12',
  21. 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  22. 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12',
  23. 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
  24. );
  25.  
  26. //Pega a extensão do arquivo
  27. $ext = pathinfo($file, PATHINFO_EXTENSION);
  28.  
  29. //usa a extensão como chave para procurar o mime correto e envia ao navegador
  30. header('Content-type: ' . $mime_types[$ext]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement