SHARE
TWEET

Untitled

a guest Jun 25th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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]);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top