Foros del Web » Programando para Internet » PHP »

[[[APORTE]]] Funcion para obtener Mime

Estas en el tema de [[[APORTE]]] Funcion para obtener Mime en el foro de PHP en Foros del Web. Buenas gente del foro, buscando por Internet a raíz de un tema que vi aquí mismo descubrí que $_FILES['Archivo']['Type] no siempre devuelve el Mime correcto ...
  #1 (permalink)  
Antiguo 10/10/2012, 15:22
Avatar de NSD
NSD
Colaborador
 
Fecha de Ingreso: mayo-2012
Ubicación: Somewhere
Mensajes: 1.332
Antigüedad: 12 años, 6 meses
Puntos: 320
Sonrisa [[[APORTE]]] Funcion para obtener Mime

Buenas gente del foro, buscando por Internet a raíz de un tema que vi aquí mismo descubrí que $_FILES['Archivo']['Type] no siempre devuelve el Mime correcto y que en su lugar lo trata como binario.

Las únicas alternativas que aparecen (algunas incluso fueron sugeridas por miembros de este foro) son salir a la consola del sistema operativo o bien usar una extensión de php.

El caso es que si estamos en un server compartido una extensión puede ser un problema con el proveedor de hosting (o en uno local si nos da fiacona instalarla)

Por tal motivo realice esta funcion que devuelve el mime correcto entre 983 tipos de archivos posibles y que no necesita nada extra para funcionar.
Código PHP:
Ver original
  1. <?php
  2.     Function GetMime($NDA) {
  3.         //Se definen en un vector los Mimes (983)
  4.         $MiMeS = [
  5.             "aw" => 'application/applixware',
  6.             "atom" => 'application/atom+xml',
  7.             "atomcat" => 'application/atomcat+xml',
  8.             "atomsvc" => 'application/atomsvc+xml',
  9.             "ccxml" => 'application/ccxml+xml',
  10.             "cdmia" => 'application/cdmi-capability',
  11.             "cdmic" => 'application/cdmi-container',
  12.             "cdmid" => 'application/cdmi-domain',
  13.             "cdmio" => 'application/cdmi-object',
  14.             "cdmiq" => 'application/cdmi-queue',
  15.             "cu" => 'application/cu-seeme',
  16.             "davmount" => 'application/davmount+xml',
  17.             "dbk" => 'application/docbook+xml',
  18.             "dssc" => 'application/dssc+der',
  19.             "xdssc" => 'application/dssc+xml',
  20.             "ecma" => 'application/ecmascript',
  21.             "emma" => 'application/emma+xml',
  22.             "epub" => 'application/epub+zip',
  23.             "exi" => 'application/exi',
  24.             "pfr" => 'application/font-tdpfr',
  25.             "gml" => 'application/gml+xml',
  26.             "gpx" => 'application/gpx+xml',
  27.             "gxf" => 'application/gxf',
  28.             "stk" => 'application/hyperstudio',
  29.             "inkml" => 'application/inkml+xml',
  30.             "ink" => 'application/inkml+xml',
  31.             "ipfix" => 'application/ipfix',
  32.             "jar" => 'application/java-archive',
  33.             "ser" => 'application/java-serialized-object',
  34.             "class" => 'application/java-vm',
  35.             "js" => 'application/javascript',
  36.             "json" => 'application/json',
  37.             "jsonml" => 'application/jsonml+json',
  38.             "lostxml" => 'application/lost+xml',
  39.             "hqx" => 'application/mac-binhex40',
  40.             "cpt" => 'application/mac-compactpro',
  41.             "mads" => 'application/mads+xml',
  42.             "mrc" => 'application/marc',
  43.             "mrcx" => 'application/marcxml+xml',
  44.             "ma" => 'application/mathematica',
  45.             "nb" => 'application/mathematica',
  46.             "mb" => 'application/mathematica',
  47.             "mathml" => 'application/mathml+xml',
  48.             "mbox" => 'application/mbox',
  49.             "mscml" => 'application/mediaservercontrol+xml',
  50.             "metalink" => 'application/metalink+xml',
  51.             "meta4" => 'application/metalink4+xml',
  52.             "mets" => 'application/mets+xml',
  53.             "mods" => 'application/mods+xml',
  54.             "m21" => 'application/mp21',
  55.             "mp21" => 'application/mp21',
  56.             "mp4s" => 'application/mp4',
  57.             "doc" => 'application/msword',
__________________
Maratón de desafíos PHP Junio - Agosto 2015 en FDW | Reglamento - Desafios
  #2 (permalink)  
Antiguo 10/10/2012, 15:25
Avatar de NSD
NSD
Colaborador
 
Fecha de Ingreso: mayo-2012
Ubicación: Somewhere
Mensajes: 1.332
Antigüedad: 12 años, 6 meses
Puntos: 320
Respuesta: [[[APORTE]]] Funcion para obtener Mime

Código PHP:
Ver original
  1. "dot" => 'application/msword',
  2.             "mxf" => 'application/mxf',
  3.             "bin" => 'application/octet-stream',
  4.             "dms" => 'application/octet-stream',
  5.             "lrf" => 'application/octet-stream',
  6.             "mar" => 'application/octet-stream',
  7.             "so" => 'application/octet-stream',
  8.             "dist" => 'application/octet-stream',
  9.             "distz" => 'application/octet-stream',
  10.             "distz" => 'application/octet-stream',
  11.             "pkg" => 'application/octet-stream',
  12.             "bpk" => 'application/octet-stream',
  13.             "dump" => 'application/octet-stream',
  14.             "elc" => 'application/octet-stream',
  15.             "deploy" => 'application/octet-stream',
  16.             "pkg" => 'application/octet-stream',
  17.             "bpk" => 'application/octet-stream',
  18.             "dump" => 'application/octet-stream',
  19.             "elc" => 'application/octet-stream',
  20.             "deploy" => 'application/octet-stream',
  21.             "oda" => 'application/oda',
  22.             "opf" => 'application/oebps-package+xml',
  23.             "ogx" => 'application/ogg',
  24.             "omdoc" => 'application/omdoc+xml',
  25.             "onetoc" => 'application/onenote',
  26.             "onetoc2" => 'application/onenote',
  27.             "onetmp" => 'application/onenote',
  28.             "onepkg" => 'application/onenote',
  29.             "oxps" => 'application/oxps',
  30.             "xer" => 'application/patch-ops-error+xml',
  31.             "pdf" => 'application/pdf',
  32.             "pgp" => 'application/pgp-encrypted',
  33.             "asc" => 'application/pgp-signature',
  34.             "sig" => 'application/pgp-signature',
  35.             "prf" => 'application/pics-rules',
  36.             "p10" => 'application/pkcs10',
  37.             "p7m" => 'application/pkcs7-mime',
  38.             "p7c" => 'application/pkcs7-mime',
  39.             "p7s" => 'application/pkcs7-signature',
  40.             "p8" => 'application/pkcs8',
  41.             "ac" => 'application/pkix-attr-cert',
  42.             "cer" => 'application/pkix-cert',
  43.             "crl" => 'application/pkix-crl',
  44.             "pkipath" => 'application/pkix-pkipath',
  45.             "pki" => 'application/pkixcmp',
  46.             "pls" => 'application/pls+xml',
  47.             "ai" => 'application/postscript',
  48.             "eps" => 'application/postscript',
  49.             "ps" => 'application/postscript',
  50.             "cww" => 'application/prs.cww',
  51.             "pskcxml" => 'application/pskc+xml',
  52.             "rdf" => 'application/rdf+xml',
  53.             "rif" => 'application/reginfo+xml',
  54.             "rnc" => 'application/relax-ng-compact-syntax',
  55.             "rl" => 'application/resource-lists+xml',
  56.             "rld" => 'application/resource-lists-diff+xml',
  57.             "rs" => 'application/rls-services+xml',
  58.             "gbr" => 'application/rpki-ghostbusters',
  59.             "mft" => 'application/rpki-manifest',
  60.             "roa" => 'application/rpki-roa',
  61.             "rsd" => 'application/rsd+xml',
  62.             "rss" => 'application/rss+xml',
  63.             "rtf" => 'application/rtf',
  64.             "sbml" => 'application/sbml+xml',
  65.             "scq" => 'application/scvp-cv-request',
  66.             "scs" => 'application/scvp-cv-response',
  67.             "spq" => 'application/scvp-vp-request',
  68.             "spp" => 'application/scvp-vp-response',
  69.             "sdp" => 'application/sdp',
  70.             "setpay" => 'application/set-payment-initiation',
  71.             "setreg" => 'application/set-registration-initiation',
  72.             "shf" => 'application/shf+xml',
  73.             "smi" => 'application/smil+xml',
  74.             "smil" => 'application/smil+xml',
  75.             "rq" => 'application/sparql-query',
  76.             "srx" => 'application/sparql-results+xml',
  77.             "gram" => 'application/srgs',
  78.             "grxml" => 'application/srgs+xml',
  79.             "sru" => 'application/sru+xml',
  80.             "ssdl" => 'application/ssdl+xml',
  81.             "ssml" => 'application/ssml+xml',
  82.             "tei" => 'application/tei+xml',
  83.             "teicorpus" => 'application/tei+xml',
  84.             "tfi" => 'application/thraud+xml',
  85.             "tsd" => 'application/timestamped-data',
  86.             "plb" => 'application/vnd.3gpp.pic-bw-large',
  87.             "psb" => 'application/vnd.3gpp.pic-bw-small',
  88.             "pvb" => 'application/vnd.3gpp.pic-bw-var',
  89.             "tcap" => 'application/vnd.3gpp2.tcap',
  90.             "pwn" => 'application/vnd.3m.post-it-notes',
  91.             "aso" => 'application/vnd.accpac.simply.aso',
  92.             "imp" => 'application/vnd.accpac.simply.imp',
  93.             "acu" => 'application/vnd.acucobol',
  94.             "atc" => 'application/vnd.acucorp',
  95.             "acutc" => 'application/vnd.acucorp',
  96.             "air" => 'application/vnd.adobe.air-application-installer-package+zip',
  97.             "fcdt" => 'application/vnd.adobe.formscentral.fcdt',
  98.             "fxp" => 'application/vnd.adobe.fxp',
  99.             "fxpl" => 'application/vnd.adobe.fxp',
  100.             "xdp" => 'application/vnd.adobe.xdp+xml',
  101.             "xfdf" => 'application/vnd.adobe.xfdf',
  102.             "ahead" => 'application/vnd.ahead.space',
  103.             "azf" => 'application/vnd.airzip.filesecure.azf',
  104.             "azs" => 'application/vnd.airzip.filesecure.azs',
  105.             "azw" => 'application/vnd.amazon.ebook',
  106.             "acc" => 'application/vnd.americandynamics.acc',
  107.             "ami" => 'application/vnd.amiga.ami',
  108.             "apk" => 'application/vnd.android.package-archive',
  109.             "cii" => 'application/vnd.anser-web-certificate-issue-initiation',
  110.             "fti" => 'application/vnd.anser-web-funds-transfer-initiation',
  111.             "atx" => 'application/vnd.antix.game-component',
  112.             "mpkg" => 'application/vnd.apple.installer+xml',
  113.             "m3u8" => 'application/vnd.apple.mpegurl',
  114.             "swi" => 'application/vnd.aristanetworks.swi',
  115.             "iota" => 'application/vnd.astraea-software.iota',
  116.             "aep" => 'application/vnd.audiograph',
  117.             "mpm" => 'application/vnd.blueice.multipass',
  118.             "bmi" => 'application/vnd.bmi',
  119.             "rep" => 'application/vnd.businessobjects',
  120.             "cdxml" => 'application/vnd.chemdraw+xml',
  121.             "mmd" => 'application/vnd.chipnuts.karaoke-mmd',
  122.             "cdy" => 'application/vnd.cinderella',
  123.             "cla" => 'application/vnd.claymore',
  124.             "rp9" => 'application/vnd.cloanto.rp9',
  125.             "c4g" => 'application/vnd.clonk.c4group',
  126.             "c4d" => 'application/vnd.clonk.c4group',
  127.             "c4f" => 'application/vnd.clonk.c4group',
  128.             "c4p" => 'application/vnd.clonk.c4group',
  129.             "c4u" => 'application/vnd.clonk.c4group',
  130.             "c11amc" => 'application/vnd.cluetrust.cartomobile-config',
  131.             "c11amz" => 'application/vnd.cluetrust.cartomobile-config-pkg',
  132.             "csp" => 'application/vnd.commonspace',
  133.             "cdbcmsg" => 'application/vnd.contact.cmsg',
  134.             "cmc" => 'application/vnd.cosmocaller',
  135.             "clkx" => 'application/vnd.crick.clicker',
  136.             "clkk" => 'application/vnd.crick.clicker.keyboard',
  137.             "clkp" => 'application/vnd.crick.clicker.palette',
  138.             "clkt" => 'application/vnd.crick.clicker.template',
  139.             "clkw" => 'application/vnd.crick.clicker.wordbank',
  140.             "wbs" => 'application/vnd.criticaltools.wbs+xml',
  141.             "pml" => 'application/vnd.ctc-posml',
  142.             "ppd" => 'application/vnd.cups-ppd',
  143.             "car" => 'application/vnd.curl.car',
  144.             "pcurl" => 'application/vnd.curl.pcurl',
  145.             "dart" => 'application/vnd.dart',
  146.             "rdz" => 'application/vnd.data-vision.rdz',
  147.             "uvf" => 'application/vnd.dece.data',
  148.             "uvvf" => 'application/vnd.dece.data',
  149.             "uvd" => 'application/vnd.dece.data',
  150.             "uvvd" => 'application/vnd.dece.data',
  151.             "uvt" => 'application/vnd.dece.ttml+xml',
  152.             "uvvt" => 'application/vnd.dece.ttml+xml',
  153.             "uvx" => 'application/vnd.dece.unspecified',
  154.             "uvvx" => 'application/vnd.dece.unspecified',
  155.             "uvz" => 'application/vnd.dece.zip',
  156.             "uvvz" => 'application/vnd.dece.zip',
  157.             "fe_launch" => 'application/vnd.denovo.fcselayout-link',
  158.             "dna" => 'application/vnd.dna',
  159.             "mlp" => 'application/vnd.dolby.mlp',
  160.             "dpg" => 'application/vnd.dpgraph',
  161.             "dfac" => 'application/vnd.dreamfactory',
  162.             "kpxx" => 'application/vnd.ds-keypoint',
  163.             "ait" => 'application/vnd.dvb.ait',
  164.             "svc" => 'application/vnd.dvb.service',
  165.             "geo" => 'application/vnd.dynageo',
  166.             "mag" => 'application/vnd.ecowin.chart',
  167.             "nml" => 'application/vnd.enliven',
  168.             "esf" => 'application/vnd.epson.esf',
  169.             "msf" => 'application/vnd.epson.msf',
  170.             "qam" => 'application/vnd.epson.quickanime',
  171.             "slt" => 'application/vnd.epson.salt',
  172.             "ssf" => 'application/vnd.epson.ssf',
  173.             "es3" => 'application/vnd.eszigno3+xml',
  174.             "et3" => 'application/vnd.eszigno3+xml',
  175.             "ez2" => 'application/vnd.ezpix-album',
  176.             "ez3" => 'application/vnd.ezpix-package',
  177.             "fdf" => 'application/vnd.fdf',
  178.             "mseed" => 'application/vnd.fdsn.mseed',
  179.             "seed" => 'application/vnd.fdsn.seed',
  180.             "dataless" => 'application/vnd.fdsn.seed',
  181.             "gph" => 'application/vnd.flographit',
  182.             "ftc" => 'application/vnd.fluxtime.clip',
  183.             "fm" => 'application/vnd.framemaker',
  184.             "frame" => 'application/vnd.framemaker',
  185.             "maker" => 'application/vnd.framemaker',
  186.             "book" => 'application/vnd.framemaker',
  187.             "fnc" => 'application/vnd.frogans.fnc',
  188.             "ltf" => 'application/vnd.frogans.ltf',
  189.             "fsc" => 'application/vnd.fsc.weblaunch',
  190.             "oas" => 'application/vnd.fujitsu.oasys',
  191.             "oa2" => 'application/vnd.fujitsu.oasys2',
  192.             "oa3" => 'application/vnd.fujitsu.oasys3',
  193.             "fg5" => 'application/vnd.fujitsu.oasysgp',
  194.             "bh2" => 'application/vnd.fujitsu.oasysprs',
  195.             "ddd" => 'application/vnd.fujixerox.ddd',
  196.             "xdw" => 'application/vnd.fujixerox.docuworks',
  197.             "xbd" => 'application/vnd.fujixerox.docuworks.binder',
  198.             "fzs" => 'application/vnd.fuzzysheet',
  199.             "txd" => 'application/vnd.genomatix.tuxedo',
  200.             "ggb" => 'application/vnd.geogebra.file',
  201.             "ggt" => 'application/vnd.geogebra.tool',
  202.             "gex" => 'application/vnd.geometry-explorer',
  203.             "gre" => 'application/vnd.geometry-explorer',
  204.             "gxt" => 'application/vnd.geonext',
  205.             "g2w" => 'application/vnd.geoplan',
  206.             "g3w" => 'application/vnd.geospace',
  207.             "gmx" => 'application/vnd.gmx',
__________________
Maratón de desafíos PHP Junio - Agosto 2015 en FDW | Reglamento - Desafios
  #3 (permalink)  
Antiguo 10/10/2012, 15:25
Avatar de NSD
NSD
Colaborador
 
Fecha de Ingreso: mayo-2012
Ubicación: Somewhere
Mensajes: 1.332
Antigüedad: 12 años, 6 meses
Puntos: 320
Respuesta: [[[APORTE]]] Funcion para obtener Mime

Código PHP:
Ver original
  1. "kml" => 'application/vnd.google-earth.kml+xml',
  2.             "kmz" => 'application/vnd.google-earth.kmz',
  3.             "gqf" => 'application/vnd.grafeq',
  4.             "gqs" => 'application/vnd.grafeq',
  5.             "gac" => 'application/vnd.groove-account',
  6.             "ghf" => 'application/vnd.groove-help',
  7.             "gim" => 'application/vnd.groove-identity-message',
  8.             "grv" => 'application/vnd.groove-injector',
  9.             "gtm" => 'application/vnd.groove-tool-message',
  10.             "tpl" => 'application/vnd.groove-tool-template',
  11.             "vcg" => 'application/vnd.groove-vcard',
  12.             "hal" => 'application/vnd.hal+xml',
  13.             "zmm" => 'application/vnd.handheld-entertainment+xml',
  14.             "hbci" => 'application/vnd.hbci',
  15.             "les" => 'application/vnd.hhe.lesson-player',
  16.             "hpgl" => 'application/vnd.hp-hpgl',
  17.             "hpid" => 'application/vnd.hp-hpid',
  18.             "hps" => 'application/vnd.hp-hps',
  19.             "jlt" => 'application/vnd.hp-jlyt',
  20.             "pcl" => 'application/vnd.hp-pcl',
  21.             "pclxl" => 'application/vnd.hp-pclxl',
  22.             "sfd-hdstx" => 'application/vnd.hydrostatix.sof-data',
  23.             "mpy" => 'application/vnd.ibm.minipay',
  24.             "afp" => 'application/vnd.ibm.modcap',
  25.             "oxt" => 'application/vnd.openofficeorg.extension',
  26.             "pptx" => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
  27.             "sldx" => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
  28.             "ppsx" => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
  29.             "potx" => 'application/vnd.openxmlformats-officedocument.presentationml.template',
  30.             "xlsx" => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  31.             "xltx" => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
  32.             "docx" => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  33.             "dotx" => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
  34.             "mgp" => 'application/vnd.osgeo.mapguide.package',
  35.             "dp" => 'application/vnd.osgi.dp',
  36.             "esa" => 'application/vnd.osgi.subsystem',
  37.             "pdb" => 'application/vnd.palm',
  38.             "pqa" => 'application/vnd.palm',
  39.             "oprc" => 'application/vnd.palm',
  40.             "paw" => 'application/vnd.pawaafile',
  41.             "str" => 'application/vnd.pg.format',
  42.             "ei6" => 'application/vnd.pg.osasli',
  43.             "efif" => 'application/vnd.picsel',
  44.             "wg" => 'application/vnd.pmi.widget',
  45.             "plf" => 'application/vnd.pocketlearn',
  46.             "pbd" => 'application/vnd.powerbuilder6',
  47.             "box" => 'application/vnd.previewsystems.box',
  48.             "mgz" => 'application/vnd.proteus.magazine',
  49.             "qps" => 'application/vnd.publishare-delta-tree',
  50.             "ptid" => 'application/vnd.pvi.ptid1',
  51.             "qxd" => 'application/vnd.quark.quarkxpress',
  52.             "qxt" => 'application/vnd.quark.quarkxpress',
  53.             "qwd" => 'application/vnd.quark.quarkxpress',
  54.             "qwt" => 'application/vnd.quark.quarkxpress',
  55.             "qxl" => 'application/vnd.quark.quarkxpress',
  56.             "qxb" => 'application/vnd.quark.quarkxpress',
  57.             "bed" => 'application/vnd.realvnc.bed',
  58.             "mxl" => 'application/vnd.recordare.musicxml',
  59.             "musicxml" => 'application/vnd.recordare.musicxml+xml',
  60.             "cryptonote" => 'application/vnd.rig.cryptonote',
  61.             "cod" => 'application/vnd.rim.cod',
  62.             "rm" => 'application/vnd.rn-realmedia',
  63.             "rmvb" => 'application/vnd.rn-realmedia-vbr',
  64.             "link66" => 'application/vnd.route66.link66+xml',
  65.             "st" => 'application/vnd.sailingtracker.track',
  66.             "see" => 'application/vnd.seemail',
  67.             "sema" => 'application/vnd.sema',
  68.             "semd" => 'application/vnd.semd',
  69.             "semf" => 'application/vnd.semf',
  70.             "ifm" => 'application/vnd.shana.informed.formdata',
  71.             "itp" => 'application/vnd.shana.informed.formtemplate',
  72.             "iif" => 'application/vnd.shana.informed.interchange',
  73.             "ipk" => 'application/vnd.shana.informed.package',
  74.             "twd" => 'application/vnd.simtech-mindmapper',
  75.             "twds" => 'application/vnd.simtech-mindmapper',
  76.             "mmf" => 'application/vnd.smaf',
  77.             "teacher" => 'application/vnd.smart.teacher',
  78.             "sdkm" => 'application/vnd.solent.sdkm+xml',
  79.             "sdkd" => 'application/vnd.solent.sdkm+xml',
  80.             "dxp" => 'application/vnd.spotfire.dxp',
  81.             "sfs" => 'application/vnd.spotfire.sfs',
  82.             "sdc" => 'application/vnd.stardivision.calc',
  83.             "sda" => 'application/vnd.stardivision.draw',
  84.             "sdd" => 'application/vnd.stardivision.impress',
  85.             "smf" => 'application/vnd.stardivision.math',
  86.             "sdw" => 'application/vnd.stardivision.writer',
  87.             "vor" => 'application/vnd.stardivision.writer',
  88.             "sgl" => 'application/vnd.stardivision.writer-global',
  89.             "smzip" => 'application/vnd.stepmania.package',
  90.             "sm" => 'application/vnd.stepmania.stepchart',
  91.             "sxc" => 'application/vnd.sun.xml.calc',
  92.             "stc" => 'application/vnd.sun.xml.calc.template',
  93.             "sxd" => 'application/vnd.sun.xml.draw',
  94.             "std" => 'application/vnd.sun.xml.draw.template',
  95.             "sxi" => 'application/vnd.sun.xml.impress',
  96.             "sti" => 'application/vnd.sun.xml.impress.template',
  97.             "sxm" => 'application/vnd.sun.xml.math',
  98.             "sxw" => 'application/vnd.sun.xml.writer',
  99.             "sxg" => 'application/vnd.sun.xml.writer.global',
  100.             "stw" => 'application/vnd.sun.xml.writer.template',
  101.             "sus" => 'application/vnd.sus-calendar',
  102.             "susp" => 'application/vnd.sus-calendar',
  103.             "svd" => 'application/vnd.svd',
  104.             "sis" => 'application/vnd.symbian.install',
  105.             "sisx" => 'application/vnd.symbian.install',
  106.             "xsm" => 'application/vnd.syncml+xml',
  107.             "bdm" => 'application/vnd.syncml.dm+wbxml',
  108.             "xdm" => 'application/vnd.syncml.dm+xml',
  109.             "tao" => 'application/vnd.tao.intent-module-archive',
  110.             "pcap" => 'application/vnd.tcpdump.pcap',
  111.             "cap" => 'application/vnd.tcpdump.pcap',
  112.             "dmp" => 'application/vnd.tcpdump.pcap',
  113.             "tmo" => 'application/vnd.tmobile-livetv',
  114.             "tpt" => 'application/vnd.trid.tpt',
  115.             "mxs" => 'application/vnd.triscape.mxs',
  116.             "tra" => 'application/vnd.trueapp',
  117.             "ufd" => 'application/vnd.ufdl',
  118.             "ufdl" => 'application/vnd.ufdl',
  119.             "utz" => 'application/vnd.uiq.theme',
  120.             "umj" => 'application/vnd.umajin',
  121.             "unityweb" => 'application/vnd.unity',
  122.             "uoml" => 'application/vnd.uoml+xml',
  123.             "vcx" => 'application/vnd.vcx',
  124.             "vsd" => 'application/vnd.visio',
  125.             "vst" => 'application/vnd.visio',
  126.             "vss" => 'application/vnd.visio',
  127.             "vsw" => 'application/vnd.visio',
  128.             "vis" => 'application/vnd.visionary',
  129.             "vsf" => 'application/vnd.vsf',
  130.             "wbxml" => 'application/vnd.wap.wbxml',
  131.             "wmlc" => 'application/vnd.wap.wmlc',
  132.             "wmlsc" => 'application/vnd.wap.wmlscriptc',
  133.             "wtb" => 'application/vnd.webturbo',
  134.             "nbp" => 'application/vnd.wolfram.player',
  135.             "wpd" => 'application/vnd.wordperfect',
  136.             "wqd" => 'application/vnd.wqd',
  137.             "stf" => 'application/vnd.wt.stf',
  138.             "xar" => 'application/vnd.xara',
  139.             "xfdl" => 'application/vnd.xfdl',
  140.             "hvd" => 'application/vnd.yamaha.hv-dic',
  141.             "hvs" => 'application/vnd.yamaha.hv-script',
  142.             "hvp" => 'application/vnd.yamaha.hv-voice',
  143.             "osf" => 'application/vnd.yamaha.openscoreformat',
  144.             "osfpvg" => 'application/vnd.yamaha.openscoreformat.osfpvg+xml',
  145.             "saf" => 'application/vnd.yamaha.smaf-audio',
  146.             "spf" => 'application/vnd.yamaha.smaf-phrase',
  147.             "cmp" => 'application/vnd.yellowriver-custom-menu',
  148.             "zir" => 'application/vnd.zul',
  149.             "zirz" => 'application/vnd.zul',
  150.             "zaz" => 'application/vnd.zzazz.deck+xml',
  151.             "wgt" => 'application/widget',
  152.             "hlp" => 'application/winhlp',
  153.             "wsdl" => 'application/wsdl+xml',
  154.             "wspolicy" => 'application/wspolicy+xml',
  155.             "7z" => 'application/x-7z-compressed',
  156.             "abw" => 'application/x-abiword',
  157.             "ace" => 'application/x-ace-compressed',
  158.             "dmg" => 'application/x-apple-diskimage',
  159.             "aab" => 'application/x-authorware-bin',
  160.             "x32" => 'application/x-authorware-bin',
  161.             "u32" => 'application/x-authorware-bin',
  162.             "vox" => 'application/x-authorware-bin',
  163.             "aam" => 'application/x-authorware-map',
  164.             "aas" => 'application/x-authorware-seg',
  165.             "bcpio" => 'application/x-bcpio',
  166.             "torrent" => 'application/x-bittorrent',
  167.             "blb" => 'application/x-blorb',
  168.             "blorb" => 'application/x-blorb',
  169.             "bz" => 'application/x-bzip',
  170.             "bz2" => 'application/x-bzip2',
  171.             "boz" => 'application/x-bzip2',
  172.             "cbr" => 'application/x-cbr',
  173.             "cba" => 'application/x-cbr',
  174.             "cbt" => 'application/x-cbr',
  175.             "cbz" => 'application/x-cbr',
  176.             "cb7" => 'application/x-cbr',
  177.             "vcd" => 'application/x-cdlink',
  178.             "cfs" => 'application/x-cfs-compressed',
  179.             "chat" => 'application/x-chat',
  180.             "pgn" => 'application/x-chess-pgn',
  181.             "nsc" => 'application/x-conference',
  182.             "cpio" => 'application/x-cpio',
  183.             "csh" => 'application/x-csh',
  184.             "deb" => 'application/x-debian-package',
  185.             "udeb" => 'application/x-debian-package',
  186.             "dgc" => 'application/x-dgc-compressed',
  187.             "dir" => 'application/x-director',
  188.             "dcr" => 'application/x-director',
  189.             "dxr" => 'application/x-director',
  190.             "cst" => 'application/x-director',
  191.             "cct" => 'application/x-director',
  192.             "cxt" => 'application/x-director',
  193.             "w3d" => 'application/x-director',
  194.             "fgd" => 'application/x-director',
  195.             "swa" => 'application/x-director',
  196.             "wad" => 'application/x-doom',
  197.             "ncx" => 'application/x-dtbncx+xml',
  198.             "dtb" => 'application/x-dtbook+xml',
  199.             "res" => 'application/x-dtbresource+xml',
  200.             "dvi" => 'application/x-dvi',
  201.             "evy" => 'application/x-envoy',
  202.             "eva" => 'application/x-eva',
  203.             "bdf" => 'application/x-font-bdf',
  204.             "gsf" => 'application/x-font-ghostscript',
  205.             "psf" => 'application/x-font-linux-psf',
  206.             "otf" => 'application/x-font-otf',
  207.             "pcf" => 'application/x-font-pcf',
  208.             "snf" => 'application/x-font-snf',
  209.             "ttf" => 'application/x-font-ttf',
  210.             "ttc" => 'application/x-font-ttf',
  211.             "pfa" => 'application/x-font-type1',
  212.             "pfb" => 'application/x-font-type1',
  213.             "pfm" => 'application/x-font-type1',
  214.             "afm" => 'application/x-font-type1',
  215.             "woff" => 'application/x-font-woff',
__________________
Maratón de desafíos PHP Junio - Agosto 2015 en FDW | Reglamento - Desafios
  #4 (permalink)  
Antiguo 10/10/2012, 15:26
Avatar de NSD
NSD
Colaborador
 
Fecha de Ingreso: mayo-2012
Ubicación: Somewhere
Mensajes: 1.332
Antigüedad: 12 años, 6 meses
Puntos: 320
Respuesta: [[[APORTE]]] Funcion para obtener Mime

Código PHP:
Ver original
  1. "arc" => 'application/x-freearc',
  2.             "spl" => 'application/x-futuresplash',
  3.             "gca" => 'application/x-gca-compressed',
  4.             "ulx" => 'application/x-glulx',
  5.             "gnumeric" => 'application/x-gnumeric',
  6.             "gramps" => 'application/x-gramps-xml',
  7.             "gtar" => 'application/x-gtar',
  8.             "hdf" => 'application/x-hdf',
  9.             "install" => 'application/x-install-instructions',
  10.             "iso" => 'application/x-iso9660-image',
  11.             "jnlp" => 'application/x-java-jnlp-file',
  12.             "latex" => 'application/x-latex',
  13.             "lzh" => 'application/x-lzh-compressed',
  14.             "lha" => 'application/x-lzh-compressed',
  15.             "mie" => 'application/x-mie',
  16.             "prc" => 'application/x-mobipocket-ebook',
  17.             "mobi" => 'application/x-mobipocket-ebook',
  18.             "application" => 'application/x-ms-application',
  19.             "lnk" => 'application/x-ms-shortcut',
  20.             "wmd" => 'application/x-ms-wmd',
  21.             "wmz" => 'application/x-ms-wmz',
  22.             "xbap" => 'application/x-ms-xbap',
  23.             "mdb" => 'application/x-msaccess',
  24.             "obd" => 'application/x-msbinder',
  25.             "crd" => 'application/x-mscardfile',
  26.             "clp" => 'application/x-msclip',
  27.             "exe" => 'application/x-msdownload',
  28.             "dll" => 'application/x-msdownload',
  29.             "com" => 'application/x-msdownload',
  30.             "bat" => 'application/x-msdownload',
  31.             "msi" => 'application/x-msdownload',
  32.             "mvb" => 'application/x-msmediaview',
  33.             "m13" => 'application/x-msmediaview',
  34.             "m14" => 'application/x-msmediaview',
  35.             "wmf" => 'application/x-msmetafile',
  36.             "wmz" => 'application/x-msmetafile',
  37.             "emf" => 'application/x-msmetafile',
  38.             "emz" => 'application/x-msmetafile',
  39.             "mny" => 'application/x-msmoney',
  40.             "pub" => 'application/x-mspublisher',
  41.             "scd" => 'application/x-msschedule',
  42.             "trm" => 'application/x-msterminal',
  43.             "wri" => 'application/x-mswrite',
  44.             "nc" => 'application/x-netcdf',
  45.             "cdf" => 'application/x-netcdf',
  46.             "nzb" => 'application/x-nzb',
  47.             "p12" => 'application/x-pkcs12',
  48.             "pfx" => 'application/x-pkcs12',
  49.             "p7b" => 'application/x-pkcs7-certificates',
  50.             "spc" => 'application/x-pkcs7-certificates',
  51.             "p7r" => 'application/x-pkcs7-certreqresp',
  52.             "rar" => 'application/x-rar-compressed',
  53.             "ris" => 'application/x-research-info-systems',
  54.             "sh" => 'application/x-sh',
  55.             "shar" => 'application/x-shar',
  56.             "swf" => 'application/x-shockwave-flash',
  57.             "xap" => 'application/x-silverlight-app',
  58.             "sql" => 'application/x-sql',
  59.             "sit" => 'application/x-stuffit',
  60.             "sitx" => 'application/x-stuffitx',
  61.             "srt" => 'application/x-subrip',
  62.             "sv4cpio" => 'application/x-sv4cpio',
  63.             "sv4crc" => 'application/x-sv4crc',
  64.             "t3" => 'application/x-t3vm-image',
  65.             "gam" => 'application/x-tads',
  66.             "tar" => 'application/x-tar',
  67.             "tcl" => 'application/x-tcl',
  68.             "tex" => 'application/x-tex',
  69.             "tfm" => 'application/x-tex-tfm',
  70.             "texinfo" => 'application/x-texinfo',
  71.             "texi" => 'application/x-texinfo',
  72.             "obj" => 'application/x-tgif',
  73.             "ustar" => 'application/x-ustar',
  74.             "src" => 'application/x-wais-source',
  75.             "der" => 'application/x-x509-ca-cert',
  76.             "crt" => 'application/x-x509-ca-cert',
  77.             "fig" => 'application/x-xfig',
  78.             "xlf" => 'application/x-xliff+xml',
  79.             "xpi" => 'application/x-xpinstall',
  80.             "xz" => 'application/x-xz',
  81.             "z1" => 'application/x-zmachine',
  82.             "z2" => 'application/x-zmachine',
  83.             "z3" => 'application/x-zmachine',
  84.             "z4" => 'application/x-zmachine',
  85.             "z5" => 'application/x-zmachine',
  86.             "z6" => 'application/x-zmachine',
  87.             "z7" => 'application/x-zmachine',
  88.             "z8" => 'application/x-zmachine',
  89.             "xaml" => 'application/xaml+xml',
  90.             "xdf" => 'application/xcap-diff+xml',
  91.             "xenc" => 'application/xenc+xml',
  92.             "xhtml" => 'application/xhtml+xml',
  93.             "xht" => 'application/xhtml+xml',
  94.             "xml" => 'application/xml',
  95.             "xsl" => 'application/xml',
  96.             "dtd" => 'application/xml-dtd',
  97.             "xop" => 'application/xop+xml',
  98.             "xpl" => 'application/xproc+xml',
  99.             "xslt" => 'application/xslt+xml',
  100.             "xspf" => 'application/xspf+xml',
  101.             "mxml" => 'application/xv+xml',
  102.             "xhvml" => 'application/xv+xml',
  103.             "xvml" => 'application/xv+xml',
  104.             "xvm" => 'application/xv+xml',
  105.             "yang" => 'application/yang',
  106.             "yin" => 'application/yin+xml',
  107.             "zip" => 'application/zip',
  108.             "adp" => 'audio/adpcm',
  109.             "au" => 'audio/basic',
  110.             "snd" => 'audio/basic',
  111.             "mid" => 'audio/midi',
  112.             "midi" => 'audio/midi',
  113.             "kar" => 'audio/midi',
  114.             "rmi" => 'audio/midi',
  115.             "mp4a" => 'audio/mp4',
  116.             "mpga" => 'audio/mpeg',
  117.             "mp2" => 'audio/mpeg',
  118.             "mp2a" => 'audio/mpeg',
  119.             "mp3" => 'audio/mpeg',
  120.             "m2a" => 'audio/mpeg',
  121.             "m3a" => 'audio/mpeg',
  122.             "oga" => 'audio/ogg',
  123.             "ogg" => 'audio/ogg',
  124.             "spx" => 'audio/ogg',
  125.             "s3m" => 'audio/s3m',
  126.             "sil" => 'audio/silk',
  127.             "uva" => 'audio/vnd.dece.audio',
  128.             "uvva" => 'audio/vnd.dece.audio',
  129.             "eol" => 'audio/vnd.digital-winds',
  130.             "dra" => 'audio/vnd.dra',
  131.             "dts" => 'audio/vnd.dts',
  132.             "dtshd" => 'audio/vnd.dts.hd',
  133.             "lvp" => 'audio/vnd.lucent.voice',
  134.             "pya" => 'audio/vnd.ms-playready.media.pya',
  135.             "ecelp4800" => 'audio/vnd.nuera.ecelp4800',
  136.             "ecelp7470" => 'audio/vnd.nuera.ecelp7470',
  137.             "ecelp9600" => 'audio/vnd.nuera.ecelp9600',
  138.             "weba" => 'audio/webm',
  139.             "aac" => 'audio/x-aac',
  140.             "aif" => 'audio/x-aiff',
  141.             "aiff" => 'audio/x-aiff',
  142.             "aifc" => 'audio/x-aiff',
  143.             "caf" => 'audio/x-caf',
  144.             "flac" => 'audio/x-flac',
  145.             "mka" => 'audio/x-matroska',
  146.             "m3u" => 'audio/x-mpegurl',
  147.             "wax" => 'audio/x-ms-wax',
  148.             "wma" => 'audio/x-ms-wma',
  149.             "ram" => 'audio/x-pn-realaudio',
  150.             "ra" => 'audio/x-pn-realaudio',
  151.             "rmp" => 'audio/x-pn-realaudio-plugin',
  152.             "wav" => 'audio/x-wav',
  153.             "xm" => 'audio/xm',
  154.             "cdx" => 'chemical/x-cdx',
  155.             "cif" => 'chemical/x-cif',
  156.             "cmdf" => 'chemical/x-cmdf',
  157.             "cml" => 'chemical/x-cml',
  158.             "csml" => 'chemical/x-csml',
  159.             "xyz" => 'chemical/x-xyz',
  160.             "bmp" => 'image/bmp',
  161.             "cgm" => 'image/cgm',
  162.             "g3" => 'image/g3fax',
  163.             "gif" => 'image/gif',
  164.             "ief" => 'image/ief',
  165.             "jpeg" => 'image/jpeg',
  166.             "jpg" => 'image/jpeg',
  167.             "jpe" => 'image/jpeg',
  168.             "ktx" => 'image/ktx',
  169.             "png" => 'image/png',
  170.             "btif" => 'image/prs.btif',
  171.             "sgi" => 'image/sgi',
  172.             "svg" => 'image/svg+xml',
  173.             "svgz" => 'image/svg+xml',
  174.             "tiff" => 'image/tiff',
  175.             "tif" => 'image/tiff',
  176.             "psd" => 'image/vnd.adobe.photoshop',
  177.             "uvi" => 'image/vnd.dece.graphic',
  178.             "uvvi" => 'image/vnd.dece.graphic',
  179.             "uvg" => 'image/vnd.dece.graphic',
  180.             "uvvg" => 'image/vnd.dece.graphic',
  181.             "sub" => 'text/vnd.dvb.subtitle',
  182.             "djvu" => 'image/vnd.djvu',
  183.             "djv" => 'image/vnd.djvu',
  184.             "dwg" => 'image/vnd.dwg',
  185.             "dxf" => 'image/vnd.dxf',
  186.             "fbs" => 'image/vnd.fastbidsheet',
  187.             "fpx" => 'image/vnd.fpx',
  188.             "fst" => 'image/vnd.fst',
  189.             "mmr" => 'image/vnd.fujixerox.edmics-mmr',
  190.             "rlc" => 'image/vnd.fujixerox.edmics-rlc',
  191.             "mdi" => 'image/vnd.ms-modi',
  192.             "wdp" => 'image/vnd.ms-photo',
  193.             "npx" => 'image/vnd.net-fpx',
  194.             "wbmp" => 'image/vnd.wap.wbmp',
  195.             "xif" => 'image/vnd.xiff',
  196.             "webp" => 'image/webp',
  197.             "3ds" => 'image/x-3ds',
  198.             "ras" => 'image/x-cmu-raster',
  199.             "cmx" => 'image/x-cmx',
  200.             "fh" => 'image/x-freehand',
  201.             "fhc" => 'image/x-freehand',
  202.             "fh4" => 'image/x-freehand',
  203.             "fh5" => 'image/x-freehand',
  204.             "fh7" => 'image/x-freehand',
  205.             "ico" => 'image/x-icon',
  206.             "sid" => 'image/x-mrsid-image',
  207.             "pcx" => 'image/x-pcx',
  208.             "pic" => 'image/x-pict',
  209.             "pct" => 'image/x-pict',
  210.             "pnm" => 'image/x-portable-anymap',
  211.             "pbm" => 'image/x-portable-bitmap',
  212.             "pgm" => 'image/x-portable-graymap',
  213.             "ppm" => 'image/x-portable-pixmap',
  214.             "rgb" => 'image/x-rgb',
  215.             "tga" => 'image/x-tga',
  216.             "xbm" => 'image/x-xbitmap',
  217.             "xpm" => 'image/x-xpixmap',
  218.             "xwd" => 'image/x-xwindowdump',
  219.             "eml" => 'message/rfc822',
  220.             "mime" => 'message/rfc822',
  221.             "igs" => 'model/iges',
  222.             "iges" => 'model/iges',
  223.             "msh" => 'model/mesh',
  224.             "mesh" => 'model/mesh',
  225.             "silo" => 'model/mesh',
  226.             "dae" => 'model/vnd.collada+xml',
  227.             "dwf" => 'model/vnd.dwf',
  228.             "gdl" => 'model/vnd.gdl',
  229.             "gtw" => 'model/vnd.gtw',
  230.             "mts" => 'model/vnd.mts',
  231.             "vtu" => 'model/vnd.vtu',
  232.             "wrl" => 'model/vrml',
  233.             "vrml" => 'model/vrml',
  234.             "x3db" => 'model/x3d+binary',
  235.             "x3dbz" => 'model/x3d+binary',
  236.             "x3dv" => 'model/x3d+vrml',
  237.             "x3dvz" => 'model/x3d+vrml',
  238.             "x3d" => 'model/x3d+xml',
  239.             "x3dz" => 'model/x3d+xml',
  240.             "appcache" => 'text/cache-manifest',
  241.             "ics" => 'text/calendar',
  242.             "ifb" => 'text/calendar',
  243.             "css" => 'text/css',
  244.             "csv" => 'text/csv',
  245.             "html" => 'text/html',
  246.             "htm" => 'text/html',
  247.             "n3" => 'text/n3',
  248.             "txt" => 'text/plain',
  249.             "text" => 'text/plain',
  250.             "conf" => 'text/plain',
  251.             "def" => 'text/plain',
  252.             "list" => 'text/plain',
  253.             "log" => 'text/plain',
  254.             "in" => 'text/plain',
  255.             "dsc" => 'text/prs.lines.tag',
  256.             "rtx" => 'text/richtext',
  257.             "sgml" => 'text/sgml',
  258.             "sgm" => 'text/sgml',
  259.             "tsv" => 'text/tab-separated-values',
  260.             "t" => 'text/troff',
  261.             "tr" => 'text/troff',
  262.             "roff" => 'text/troff',
  263.             "man" => 'text/troff',
  264.             "me" => 'text/troff',
  265.             "ms" => 'text/troff',
  266.             "ttl" => 'text/turtle',
  267.             "uri" => 'text/uri-list',
  268.             "uris" => 'text/uri-list',
  269.             "urls" => 'text/uri-list',
  270.             "vcard" => 'text/vcard',
  271.             "curl" => 'text/vnd.curl',
  272.             "dcurl" => 'text/vnd.curl.dcurl',
  273.             "scurl" => 'text/vnd.curl.scurl',
  274.             "mcurl" => 'text/vnd.curl.mcurl',
  275.             "fly" => 'text/vnd.fly',
  276.             "flx" => 'text/vnd.fmi.flexstor',
  277.             "gv" => 'text/vnd.graphviz',
  278.             "3dml" => 'text/vnd.in3d.3dml',
  279.             "spot" => 'text/vnd.in3d.spot',
  280.             "jad" => 'text/vnd.sun.j2me.app-descriptor',
  281.             "wml" => 'text/vnd.wap.wml',
  282.             "wmls" => 'text/vnd.wap.wmlscript',
  283.             "s" => 'text/x-asm',
  284.             "asm" => 'text/x-asm',
  285.             "c" => 'text/x-c',
  286.             "cc" => 'text/x-c',
  287.             "cxx" => 'text/x-c',
  288.             "cpp" => 'text/x-c',
  289.             "h" => 'text/x-c',
__________________
Maratón de desafíos PHP Junio - Agosto 2015 en FDW | Reglamento - Desafios
  #5 (permalink)  
Antiguo 10/10/2012, 15:26
Avatar de NSD
NSD
Colaborador
 
Fecha de Ingreso: mayo-2012
Ubicación: Somewhere
Mensajes: 1.332
Antigüedad: 12 años, 6 meses
Puntos: 320
Respuesta: [[[APORTE]]] Funcion para obtener Mime

Código PHP:
Ver original
  1. "hh" => 'text/x-c',
  2.             "dic" => 'text/x-c',
  3.             "f" => 'text/x-fortran',
  4.             "for" => 'text/x-fortran',
  5.             "f77" => 'text/x-fortran',
  6.             "f90" => 'text/x-fortran',
  7.             "java" => 'text/x-java-source',
  8.             "opml" => 'text/x-opml',
  9.             "p" => 'text/x-pascal',
  10.             "pas" => 'text/x-pascal',
  11.             "nfo" => 'text/x-nfo',
  12.             "etx" => 'text/x-setext',
  13.             "sfv" => 'text/x-sfv',
  14.             "uu" => 'text/x-uuencode',
  15.             "vcs" => 'text/x-vcalendar',
  16.             "vcf" => 'text/x-vcard',
  17.             "3gp" => 'video/3gpp',
  18.             "3g2" => 'video/3gpp2',
  19.             "h261" => 'video/h261',
  20.             "h263" => 'video/h263',
  21.             "h264" => 'video/h264',
  22.             "jpgv" => 'video/jpeg',
  23.             "jpm" => 'video/jpm',
  24.             "jpgm" => 'video/jpm',
  25.             "mj2" => 'video/mj2',
  26.             "mjp2" => 'video/mj2',
  27.             "mp4" => 'video/mp4',
  28.             "mp4v" => 'video/mp4',
  29.             "mpg4" => 'video/mp4',
  30.             "mpeg" => 'video/mpeg',
  31.             "mpg" => 'video/mpeg',
  32.             "mpe" => 'video/mpeg',
  33.             "m1v" => 'video/mpeg',
  34.             "m2v" => 'video/mpeg',
  35.             "ogv" => 'video/ogg',
  36.             "qt" => 'video/quicktime',
  37.             "mov" => 'video/quicktime',
  38.             "uvh" => 'video/vnd.dece.hd',
  39.             "uvvh" => 'video/vnd.dece.hd',
  40.             "uvm" => 'video/vnd.dece.mobile',
  41.             "uvvm" => 'video/vnd.dece.mobile',
  42.             "uvp" => 'video/vnd.dece.pd',
  43.             "uvvp" => 'video/vnd.dece.pd',
  44.             "uvs" => 'video/vnd.dece.sd',
  45.             "uvvs" => 'video/vnd.dece.sd',
  46.             "uvv" => 'video/vnd.dece.video',
  47.             "uvvv" => 'video/vnd.dece.video',
  48.             "dvb" => 'video/vnd.dvb.file',
  49.             "fvt" => 'video/vnd.fvt',
  50.             "mxu" => 'video/vnd.mpegurl',
  51.             "m4u" => 'video/vnd.mpegurl',
  52.             "pyv" => 'video/vnd.ms-playready.media.pyv',
  53.             "uvu" => 'video/vnd.uvvu.mp4',
  54.             "uvvu" => 'video/vnd.uvvu.mp4',
  55.             "viv" => 'video/vnd.vivo',
  56.             "webm" => 'video/webm',
  57.             "f4v" => 'video/x-f4v',
  58.             "fli" => 'video/x-fli',
  59.             "flv" => 'video/x-flv',
  60.             "m4v" => 'video/x-m4v',
  61.             "mkv" => 'video/x-matroska',
  62.             "mk3d" => 'video/x-matroska',
  63.             "mks" => 'video/x-matroska',
  64.             "mng" => 'video/x-mng',
  65.             "asf" => 'video/x-ms-asf',
  66.             "asx" => 'video/x-ms-asf',
  67.             "vob" => 'video/x-ms-vob',
  68.             "wm" => 'video/x-ms-wm',
  69.             "wmv" => 'video/x-ms-wmv',
  70.             "wmx" => 'video/x-ms-wmx',
  71.             "wvx" => 'video/x-ms-wvx',
  72.             "avi" => 'video/x-msvideo',
  73.             "movie" => 'video/x-sgi-movie',
  74.             "smv" => 'video/x-smv',
  75.             "ice" => 'x-conference/x-cooltalk'
  76.         ];
  77.         //Se obtiene la extencion en minusculas del archivo.
  78.         $EXT = StrToLower(End(Explode('.',$NDA)));
  79.         //Se obtiene el Mime de la extencion.
  80.         $MiMe = $MiMeS[$EXT];
  81.         //Se libera el espacio en memoria del vector MiMeS.
  82.         Unset($MiMeS);
  83.         //Si el Mime de la extencion no existe se asume que es un archivo binario.
  84.         If ($MiMe == '') { $MiMe = 'application/octet-stream'; }
  85.        
  86.         Return($MiMe);
  87.     }
  88.    
  89.     //Modo de uso:
  90.    
  91.     $NombreDeArchivo = 'Archivo.mp4';
  92.     Echo(GetMime($NombreDeArchivo));
  93. ?>

Ventajas:
  • No usa extensiones.
  • Muchos mas mimes que las funciones nativas.
  • Pueden agregarse mas mimes fácilmente.
  • Eficiente.


Contras:
  • No indica el Mime real del archivo, solo el Mime de la extensión.


Espero les sea de utilidad si en algún momento se topan con este problema.

Cualquier sugerencia para mejorarla es bienvenida, y cualquier critica mientras no sea ofensiva también es aceptada.

Saludos.

Nota:
Para almacenar el Mime resultante de esta funcion en una base de datos debera usarse un campo Char(72).

Fuentes de los Mimes:
http://svn.apache.org/viewvc/httpd/h...?view=annotate
__________________
Maratón de desafíos PHP Junio - Agosto 2015 en FDW | Reglamento - Desafios

Última edición por NSD; 10/10/2012 a las 16:45

Etiquetas: funcion, mime
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:11.