Ver Mensaje Individual
  #7 (permalink)  
Antiguo 10/07/2012, 10:30
rpichinu
 
Fecha de Ingreso: noviembre-2010
Mensajes: 208
Antigüedad: 13 años, 5 meses
Puntos: 3
Respuesta: cabeceras header para distintos tipo ejemplo png y jpeg

aaaa y de esta forma?


Código PHP:
Ver original
  1. <?php
  2. if(!function_exists('mime_content_type')) {
  3.  
  4.     function mime_content_type($filename) {
  5.  
  6.         $mime_types = array(
  7.  
  8.             'txt' => 'text/plain',
  9.             'htm' => 'text/html',
  10.             'html' => 'text/html',
  11.             'php' => 'text/html',
  12.             'css' => 'text/css',
  13.             'js' => 'application/javascript',
  14.             'json' => 'application/json',
  15.             'xml' => 'application/xml',
  16.             'swf' => 'application/x-shockwave-flash',
  17.             'flv' => 'video/x-flv',
  18.  
  19.             // images
  20.             'png' => 'image/png',
  21.             'jpe' => 'image/jpeg',
  22.             'jpeg' => 'image/jpeg',
  23.             'jpg' => 'image/jpeg',
  24.             'gif' => 'image/gif',
  25.             'bmp' => 'image/bmp',
  26.             'ico' => 'image/vnd.microsoft.icon',
  27.             'tiff' => 'image/tiff',
  28.             'tif' => 'image/tiff',
  29.             'svg' => 'image/svg+xml',
  30.             'svgz' => 'image/svg+xml',
  31.  
  32.             // archives
  33.             'zip' => 'application/zip',
  34.             'rar' => 'application/x-rar-compressed',
  35.             'exe' => 'application/x-msdownload',
  36.             'msi' => 'application/x-msdownload',
  37.             'cab' => 'application/vnd.ms-cab-compressed',
  38.  
  39.             // audio/video
  40.             'mp3' => 'audio/mpeg',
  41.             'qt' => 'video/quicktime',
  42.             'mov' => 'video/quicktime',
  43.  
  44.             // adobe
  45.             'pdf' => 'application/pdf',
  46.             'psd' => 'image/vnd.adobe.photoshop',
  47.             'ai' => 'application/postscript',
  48.             'eps' => 'application/postscript',
  49.             'ps' => 'application/postscript',
  50.  
  51.             // ms office
  52.             'doc' => 'application/msword',
  53.             'rtf' => 'application/rtf',
  54.             'xls' => 'application/vnd.ms-excel',
  55.             'ppt' => 'application/vnd.ms-powerpoint',
  56.  
  57.             // open office
  58.             'odt' => 'application/vnd.oasis.opendocument.text',
  59.             'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
  60.         );
  61.  
  62.         $ext = strtolower(array_pop(explode('.',$filename)));
  63.         if (array_key_exists($ext, $mime_types)) {
  64.             return $mime_types[$ext];
  65.         }
  66.         elseif (function_exists('finfo_open')) {
  67.             $finfo = finfo_open(FILEINFO_MIME);
  68.             $mimetype = finfo_file($finfo, $filename);
  69.             finfo_close($finfo);
  70.             return $mimetype;
  71.         }
  72.         else {
  73.             return 'application/octet-stream';
  74.         }
  75.     }
  76. }
  77. ?>