Error al subir ficheros en WordPress: Perdona, por razones de seguridad, este tipo de archivos no está permitido

Si al subir ficheros por el gestor de WordPress, nos aparece este texto de advertencia «Perdona, por razones de seguridad, este tipo de archivos no está permitido» y no nos deja subir cierta extensión de archivo, podemos arreglarlo de una manera fácil.

error wordpress subir archivos seguridad

Tan sólo tenemos que darle permiso a la plantilla para eliminar esa barrera de seguridad, buscando en el archivo funtions.php. Para ello habrá que ir a la sección APARIENCIA > EDITOR y luego buscar entre los archivos de la plantilla el de FUNCIONES DEL TEMA (functions.php).

functions wordpress plantilla

Allí habrá que añadir unas líneas al final donde podremos declarar qué clase de archivos permitiremos subir a partir de ahora. Este es un ejemplo:

add_filter('upload_mimes', 'mqw_mas_extensiones');
function mqw_mas_extensiones ( $existing_mimes=array() ) {
// Agregamos nuevas extensiones al array al lado de su MIME type:
$existing_mimes['swf'] = 'application/x-shockwave-flash';
$existing_mimes['mp3'] = 'audio/mpeg3';
//Agregamos las que necesitemos y luego retornamos el array
return $existing_mimes;
}

En este ejemplo hemos permitido dos clases de archivos nuevos, los .SWF y los .MP3. Como veis, en rojo están los nombres de la extensión de archivo, y en verde la clase MYME type que es ese archivo. Así que si queremos aplicarlo a nuestras necesidades, añadiremos tantas líneas de declaración como archivos queramos permitir, sustituyendo el texto en rojo y verde de estos ejemplos por los que necesitemos. Ejemplo para permitir subir ficheros .DOC:

add_filter('upload_mimes', 'mqw_mas_extensiones');
function mqw_mas_extensiones ( $existing_mimes=array() ) {
// Agregamos nuevas extensiones al array al lado de su MIME type:
$existing_mimes['doc'] = 'application/msword';
//Agregamos las que necesitemos y luego retornamos el array
return $existing_mimes;
}

Hay que tener cuidado cuando toquemos el fichero functions.php si no estamos muy experimentados con él, ya que este código no habrá que ponerlo exactamente al final, sino al final, pero antes de ?> que es como suele ir cerrado este archivo. De esta manera, el código quedará metido al final de todo el texto que haya, pero antes de la línea de cierre ?>

En este ejemplo de la imagen de abajo, podéis ver el texto que hemos introducido en rojo, y vemos que al final hemos dejado el cierre ?> que ya había.

final archivo functions.php

Tan sólo nos queda indicaros los MYME Type de las distintas extensiones de archivos que necesitaréis si queréis añadir los vuestros propios. En esta lista tenéis las extensiones y los MYME Type correspondientes a la derecha.

.3dmx-world/x-3dmf
.3dmfx-world/x-3dmf
.3gp (3GP Mobile)video/3gpp
.aapplication/octet-stream
.aabapplication/x-authorware-bin
.aamapplication/x-authorware-map
.aasapplication/x-authorware-seg
.abctext/vnd.abc
.acgitext/html
.aflvideo/animaflex
.aiapplication/postscript
.aifaudio/aiff
.aifaudio/x-aiff
.aifcaudio/aiff
.aifcaudio/x-aiff
.aiffaudio/aiff
.aiffaudio/x-aiff
.aimapplication/x-aim
.aiptext/x-audiosoft-intra
.aniapplication/x-navi-animation
.aosapplication/x-nokia-9000-communicator-add-on-software
.apsapplication/mime
.arcapplication/octet-stream
.arjapplication/arj
.arjapplication/octet-stream
.artimage/x-jg
.asfvideo/x-ms-asf
.asmtext/x-asm
.asptext/asp
.asxapplication/x-mplayer2
.asxvideo/x-ms-asf
.asxvideo/x-ms-asf-plugin
.auaudio/basic
.auaudio/x-au
.aviapplication/x-troff-msvideo
.avivideo/avi
.avivideo/msvideo
.avi (A/V Interleave)video/x-msvideo
.avsvideo/avs-video
.bcpioapplication/x-bcpio
.binapplication/mac-binary
.binapplication/macbinary
.binapplication/octet-stream
.binapplication/x-binary
.binapplication/x-macbinary
.bmimage/bmp
.bmpimage/bmp
.bmpimage/x-windows-bmp
.booapplication/book
.bookapplication/book
.bozapplication/x-bzip2
.bshapplication/x-bsh
.bzapplication/x-bzip
.bz2application/x-bzip2
.ctext/plain
.ctext/x-c
.c++text/plain
.catapplication/vnd.ms-pki.seccat
.cctext/plain
.cctext/x-c
.ccadapplication/clariscad
.ccoapplication/x-cocoa
.cdfapplication/cdf
.cdfapplication/x-cdf
.cdfapplication/x-netcdf
.cerapplication/pkix-cert
.cerapplication/x-x509-ca-cert
.chaapplication/x-chat
.chatapplication/x-chat
.classapplication/java
.classapplication/java-byte-code
.classapplication/x-java-class
.comapplication/octet-stream
.comtext/plain
.conftext/plain
.cpioapplication/x-cpio
.cpptext/x-c
.cptapplication/mac-compactpro
.cptapplication/x-compactpro
.cptapplication/x-cpt
.crlapplication/pkcs-crl
.crlapplication/pkix-crl
.crtapplication/pkix-cert
.crtapplication/x-x509-ca-cert
.crtapplication/x-x509-user-cert
.cshapplication/x-csh
.cshtext/x-script.csh
.cssapplication/x-pointplus
.csstext/css
.cxxtext/plain
.dcrapplication/x-director
.deepvapplication/x-deepv
.deftext/plain
.derapplication/x-x509-ca-cert
.difvideo/x-dv
.dirapplication/x-director
.dlvideo/dl
.dlvideo/x-dl
.docapplication/msword
.dotapplication/msword
.dpapplication/commonground
.drwapplication/drafting
.dumpapplication/octet-stream
.dvvideo/x-dv
.dviapplication/x-dvi
.dwfdrawing/x-dwf (old)
.dwfmodel/vnd.dwf
.dwgapplication/acad
.dwgimage/vnd.dwg
.dwgimage/x-dwg
.dxfapplication/dxf
.dxfimage/vnd.dwg
.dxfimage/x-dwg
.dxrapplication/x-director
.eltext/x-script.elisp
.elcapplication/x-bytecode.elisp (compiled elisp)
.elcapplication/x-elc
.envapplication/x-envoy
.epsapplication/postscript
.esapplication/x-esrehber
.etxtext/x-setext
.evyapplication/envoy
.evyapplication/x-envoy
.exeapplication/octet-stream
.ftext/plain
.ftext/x-fortran
.f77text/x-fortran
.f90text/plain
.f90text/x-fortran
.fdfapplication/vnd.fdf
.fifapplication/fractals
.fifimage/fif
.flivideo/fli
.flivideo/x-fli
.floimage/florian
.flv (flash)video/x-flv
.flxtext/vnd.fmi.flexstor
.fmfvideo/x-atomic3d-feature
.fortext/plain
.fortext/x-fortran
.fpximage/vnd.fpx
.fpximage/vnd.net-fpx
.frlapplication/freeloader
.funkaudio/make
.gtext/plain
.g3image/g3fax
.gifimage/gif
.glvideo/gl
.glvideo/x-gl
.gsdaudio/x-gsm
.gsmaudio/x-gsm
.gspapplication/x-gsp
.gssapplication/x-gss
.gtarapplication/x-gtar
.gzapplication/x-compressed
.gzapplication/x-gzip
.gzipapplication/x-gzip
.gzipmultipart/x-gzip
.htext/plain
.htext/x-h
.hdfapplication/x-hdf
.helpapplication/x-helpfile
.hglapplication/vnd.hp-hpgl
.hhtext/plain
.hhtext/x-h
.hlbtext/x-script
.hlpapplication/hlp
.hlpapplication/x-helpfile
.hlpapplication/x-winhelp
.hpgapplication/vnd.hp-hpgl
.hpglapplication/vnd.hp-hpgl
.hqxapplication/binhex
.hqxapplication/binhex4
.hqxapplication/mac-binhex
.hqxapplication/mac-binhex40
.hqxapplication/x-binhex40
.hqxapplication/x-mac-binhex40
.htaapplication/hta
.htctext/x-component
.htmtext/html
.htmltext/html
.htmlstext/html
.htttext/webviewhtml
.htxtext/html
.icex-conference/x-cooltalk
.icoimage/x-icon
.idctext/plain
.iefimage/ief
.iefsimage/ief
.igesapplication/iges
.igesmodel/iges
.igsapplication/iges
.igsmodel/iges
.imaapplication/x-ima
.imapapplication/x-httpd-imap
.infapplication/inf
.insapplication/x-internett-signup
.ipapplication/x-ip2
.isuvideo/x-isvideo
.itaudio/it
.ivapplication/x-inventor
.ivri-world/i-vrml
.ivyapplication/x-livescreen
.jamaudio/x-jam
.javtext/plain
.javtext/x-java-source
.javatext/plain
.javatext/x-java-source
.jcmapplication/x-java-commerce
.jfifimage/jpeg
.jfifimage/pjpeg
.jfif-tbnlimage/jpeg
.jpeimage/jpeg
.jpeimage/pjpeg
.jpegimage/jpeg
.jpegimage/pjpeg
.jpgimage/jpeg
.jpgimage/pjpeg
.jpsimage/x-jps
.jsapplication/x-javascript
.jutimage/jutvision
.karaudio/midi
.karmusic/x-karaoke
.kshapplication/x-ksh
.kshtext/x-script.ksh
.laaudio/nspaudio
.laaudio/x-nspaudio
.lamaudio/x-liveaudio
.latexapplication/x-latex
.lhaapplication/lha
.lhaapplication/octet-stream
.lhaapplication/x-lha
.lhxapplication/octet-stream
.listtext/plain
.lmaaudio/nspaudio
.lmaaudio/x-nspaudio
.logtext/plain
.lspapplication/x-lisp
.lsptext/x-script.lisp
.lsttext/plain
.lsxtext/x-la-asf
.ltxapplication/x-latex
.lzhapplication/octet-stream
.lzhapplication/x-lzh
.lzxapplication/lzx
.lzxapplication/octet-stream
.lzxapplication/x-lzx
.mtext/plain
.mtext/x-m
.m1vvideo/mpeg
.m2aaudio/mpeg
.m2vvideo/mpeg
.m3uaudio/x-mpequrl
.m3u8 (iPhone Index)application/x-mpegURL
.manapplication/x-troff-man
.mapapplication/x-navimap
.martext/plain
.mbdapplication/mbedlet
.mc$application/x-magic-cap-package-1.0
.mcdapplication/mcad
.mcdapplication/x-mathcad
.mcfimage/vasa
.mcftext/mcf
.mcpapplication/netmc
.meapplication/x-troff-me
.mhtmessage/rfc822
.mhtmlmessage/rfc822
.midapplication/x-midi
.midaudio/midi
.midaudio/x-mid
.midaudio/x-midi
.midmusic/crescendo
.midx-music/x-midi
.midiapplication/x-midi
.midiaudio/midi
.midiaudio/x-mid
.midiaudio/x-midi
.midimusic/crescendo
.midix-music/x-midi
.mifapplication/x-frame
.mifapplication/x-mif
.mimemessage/rfc822
.mimewww/mime
.mjfaudio/x-vnd.audioexplosion.mjuicemediafile
.mjpgvideo/x-motion-jpeg
.mmapplication/base64
.mmapplication/x-meme
.mmeapplication/base64
.modaudio/mod
.modaudio/x-mod
.moovvideo/quicktime
.mov (QuickTime)video/quicktime
.movievideo/x-sgi-movie
.mp2audio/mpeg
.mp2audio/x-mpeg
.mp2video/mpeg
.mp2video/x-mpeg
.mp2video/x-mpeq2a
.mp3audio/mpeg3
.mp3audio/x-mpeg-3
.mp3video/mpeg
.mp3video/x-mpeg
.mp4 (MPEG-4)video/mp4
.mpaaudio/mpeg
.mpavideo/mpeg
.mpcapplication/x-project
.mpevideo/mpeg
.mpegvideo/mpeg
.mpgaudio/mpeg
.mpgvideo/mpeg
.mpgaaudio/mpeg
.mppapplication/vnd.ms-project
.mptapplication/x-project
.mpvapplication/x-project
.mpxapplication/x-project
.mrcapplication/marc
.msapplication/x-troff-ms
.mvvideo/x-sgi-movie
.myaudio/make
.mzzapplication/x-vnd.audioexplosion.mzz
.napimage/naplps
.naplpsimage/naplps
.ncapplication/x-netcdf
.ncmapplication/vnd.nokia.configuration-message
.nifimage/x-niff
.niffimage/x-niff
.nixapplication/x-mix-transfer
.nscapplication/x-conference
.nvdapplication/x-navidoc
.oapplication/octet-stream
.odaapplication/oda
.omcapplication/x-omc
.omcdapplication/x-omcdatamaker
.omcrapplication/x-omcregerator
.ptext/x-pascal
.p10application/pkcs10
.p10application/x-pkcs10
.p12application/pkcs-12
.p12application/x-pkcs12
.p7aapplication/x-pkcs7-signature
.p7capplication/pkcs7-mime
.p7capplication/x-pkcs7-mime
.p7mapplication/pkcs7-mime
.p7mapplication/x-pkcs7-mime
.p7rapplication/x-pkcs7-certreqresp
.p7sapplication/pkcs7-signature
.partapplication/pro_eng
.pastext/pascal
.pbmimage/x-portable-bitmap
.pclapplication/vnd.hp-pcl
.pclapplication/x-pcl
.pctimage/x-pict
.pcximage/x-pcx
.pdbchemical/x-pdb
.pdfapplication/pdf
.pfunkaudio/make
.pfunkaudio/make.my.funk
.pgmimage/x-portable-graymap
.pgmimage/x-portable-greymap
.picimage/pict
.pictimage/pict
.pkgapplication/x-newton-compatible-pkg
.pkoapplication/vnd.ms-pki.pko
.pltext/plain
.pltext/x-script.perl
.plxapplication/x-pixclscript
.pmimage/x-xpixmap
.pmtext/x-script.perl-module
.pm4application/x-pagemaker
.pm5application/x-pagemaker
.pngimage/png
.pnmapplication/x-portable-anymap
.pnmimage/x-portable-anymap
.potapplication/mspowerpoint
.potapplication/vnd.ms-powerpoint
.povmodel/x-pov
.ppaapplication/vnd.ms-powerpoint
.ppmimage/x-portable-pixmap
.ppsapplication/mspowerpoint
.ppsapplication/vnd.ms-powerpoint
.pptapplication/mspowerpoint
.pptapplication/powerpoint
.pptapplication/vnd.ms-powerpoint
.pptapplication/x-mspowerpoint
.ppzapplication/mspowerpoint
.preapplication/x-freelance
.prtapplication/pro_eng
.psapplication/postscript
.psdapplication/octet-stream
.pvupaleovu/x-pv
.pwzapplication/vnd.ms-powerpoint
.pytext/x-script.phyton
.pycapplicaiton/x-bytecode.python
.qcpaudio/vnd.qcelp
.qd3x-world/x-3dmf
.qd3dx-world/x-3dmf
.qifimage/x-quicktime
.qtvideo/quicktime
.qtcvideo/x-qtc
.qtiimage/x-quicktime
.qtifimage/x-quicktime
.raaudio/x-pn-realaudio
.raaudio/x-pn-realaudio-plugin
.raaudio/x-realaudio
.ramaudio/x-pn-realaudio
.rasapplication/x-cmu-raster
.rasimage/cmu-raster
.rasimage/x-cmu-raster
.rastimage/cmu-raster
.rexxtext/x-script.rexx
.rfimage/vnd.rn-realflash
.rgbimage/x-rgb
.rmapplication/vnd.rn-realmedia
.rmaudio/x-pn-realaudio
.rmiaudio/mid
.rmmaudio/x-pn-realaudio
.rmpaudio/x-pn-realaudio
.rmpaudio/x-pn-realaudio-plugin
.rngapplication/ringing-tones
.rngapplication/vnd.nokia.ringing-tone
.rnxapplication/vnd.rn-realplayer
.roffapplication/x-troff
.rpimage/vnd.rn-realpix
.rpmaudio/x-pn-realaudio-plugin
.rttext/richtext
.rttext/vnd.rn-realtext
.rtfapplication/rtf
.rtfapplication/x-rtf
.rtftext/richtext
.rtxapplication/rtf
.rtxtext/richtext
.rvvideo/vnd.rn-realvideo
.stext/x-asm
.s3maudio/s3m
.savemeapplication/octet-stream
.sbkapplication/x-tbook
.scmapplication/x-lotusscreencam
.scmtext/x-script.guile
.scmtext/x-script.scheme
.scmvideo/x-scm
.sdmltext/plain
.sdpapplication/sdp
.sdpapplication/x-sdp
.sdrapplication/sounder
.seaapplication/sea
.seaapplication/x-sea
.setapplication/set
.sgmtext/sgml
.sgmtext/x-sgml
.sgmltext/sgml
.sgmltext/x-sgml
.shapplication/x-bsh
.shapplication/x-sh
.shapplication/x-shar
.shtext/x-script.sh
.sharapplication/x-bsh
.sharapplication/x-shar
.shtmltext/html
.shtmltext/x-server-parsed-html
.sidaudio/x-psid
.sitapplication/x-sit
.sitapplication/x-stuffit
.skdapplication/x-koan
.skmapplication/x-koan
.skpapplication/x-koan
.sktapplication/x-koan
.slapplication/x-seelogo
.smiapplication/smil
.smilapplication/smil
.sndaudio/basic
.sndaudio/x-adpcm
.solapplication/solids
.spcapplication/x-pkcs7-certificates
.spctext/x-speech
.splapplication/futuresplash
.sprapplication/x-sprite
.spriteapplication/x-sprite
.srcapplication/x-wais-source
.ssitext/x-server-parsed-html
.ssmapplication/streamingmedia
.sstapplication/vnd.ms-pki.certstore
.stepapplication/step
.stlapplication/sla
.stlapplication/vnd.ms-pki.stl
.stlapplication/x-navistyle
.stpapplication/step
.sv4cpioapplication/x-sv4cpio
.sv4crcapplication/x-sv4crc
.svfimage/vnd.dwg
.svfimage/x-dwg
.svrapplication/x-world
.svrx-world/x-svr
.swfapplication/x-shockwave-flash
.tapplication/x-troff
.talktext/x-speech
.tarapplication/x-tar
.tbkapplication/toolbook
.tbkapplication/x-tbook
.tclapplication/x-tcl
.tcltext/x-script.tcl
.tcshtext/x-script.tcsh
.texapplication/x-tex
.texiapplication/x-texinfo
.texinfoapplication/x-texinfo
.textapplication/plain
.texttext/plain
.tgzapplication/gnutar
.tgzapplication/x-compressed
.tifimage/tiff
.tifimage/x-tiff
.tiffimage/tiff
.tiffimage/x-tiff
.trapplication/x-troff
.tr (iPhone Segment)video/MP2T
.tsiaudio/tsp-audio
.tspapplication/dsptype
.tspaudio/tsplayer
.tsvtext/tab-separated-values
.turbotimage/florian
.txttext/plain
.uiltext/x-uil
.unitext/uri-list
.unistext/uri-list
.unvapplication/i-deas
.uritext/uri-list
.uristext/uri-list
.ustarapplication/x-ustar
.ustarmultipart/x-ustar
.uuapplication/octet-stream
.uutext/x-uuencode
.uuetext/x-uuencode
.vcdapplication/x-cdlink
.vcstext/x-vcalendar
.vdaapplication/vda
.vdovideo/vdo
.vewapplication/groupwise
.vivvideo/vivo
.vivvideo/vnd.vivo
.vivovideo/vivo
.vivovideo/vnd.vivo
.vmdapplication/vocaltec-media-desc
.vmfapplication/vocaltec-media-file
.vocaudio/voc
.vocaudio/x-voc
.vosvideo/vosaic
.voxaudio/voxware
.vqeaudio/x-twinvq-plugin
.vqfaudio/x-twinvq
.vqlaudio/x-twinvq-plugin
.vrmlapplication/x-vrml
.vrmlmodel/vrml
.vrmlx-world/x-vrml
.vrtx-world/x-vrt
.vsdapplication/x-visio
.vstapplication/x-visio
.vswapplication/x-visio
.w60application/wordperfect6.0
.w61application/wordperfect6.1
.w6wapplication/msword
.wavaudio/wav
.wavaudio/x-wav
.wb1application/x-qpro
.wbmpimage/vnd.wap.wbmp
.webapplication/vnd.xara
.wizapplication/msword
.wk1application/x-123
.wmfwindows/metafile
.wmltext/vnd.wap.wml
.wmlcapplication/vnd.wap.wmlc
.wmlstext/vnd.wap.wmlscript
.wmlscapplication/vnd.wap.wmlscriptc
.wmv (Windows Media Video)video/x-ms-wmv
.wordapplication/msword
.wpapplication/wordperfect
.wp5application/wordperfect
.wp5application/wordperfect6.0
.wp6application/wordperfect
.wpdapplication/wordperfect
.wpdapplication/x-wpwin
.wq1application/x-lotus
.wriapplication/mswrite
.wriapplication/x-wri
.wrlapplication/x-world
.wrlmodel/vrml
.wrlx-world/x-vrml
.wrzmodel/vrml
.wrzx-world/x-vrml
.wsctext/scriplet
.wsrcapplication/x-wais-source
.wtkapplication/x-wintalk
.xbmimage/x-xbitmap
.xbmimage/x-xbm
.xbmimage/xbm
.xdrvideo/x-amt-demorun
.xgzxgl/drawing
.xifimage/vnd.xiff
.xlapplication/excel
.xlaapplication/excel
.xlaapplication/x-excel
.xlaapplication/x-msexcel
.xlbapplication/excel
.xlbapplication/vnd.ms-excel
.xlbapplication/x-excel
.xlcapplication/excel
.xlcapplication/vnd.ms-excel
.xlcapplication/x-excel
.xldapplication/excel
.xldapplication/x-excel
.xlkapplication/excel
.xlkapplication/x-excel
.xllapplication/excel
.xllapplication/vnd.ms-excel
.xllapplication/x-excel
.xlmapplication/excel
.xlmapplication/vnd.ms-excel
.xlmapplication/x-excel
.xlsapplication/excel
.xlsapplication/vnd.ms-excel
.xlsapplication/x-excel
.xlsapplication/x-msexcel
.xltapplication/excel
.xltapplication/x-excel
.xlvapplication/excel
.xlvapplication/x-excel
.xlwapplication/excel
.xlwapplication/vnd.ms-excel
.xlwapplication/x-excel
.xlwapplication/x-msexcel
.xmaudio/xm
.xmlapplication/xml
.xmltext/xml
.xmzxgl/movie
.xpixapplication/x-vnd.ls-xpix
.xpmimage/x-xpixmap
.xpmimage/xpm
.x-pngimage/png
.xsrvideo/x-amt-showrun
.xwdimage/x-xwd
.xwdimage/x-xwindowdump
.xyzchemical/x-pdb
.zapplication/x-compress
.zapplication/x-compressed
.zipapplication/x-compressed
.zipapplication/x-zip-compressed
.zipapplication/zip
.zipmultipart/x-zip
.zooapplication/octet-stream
.zshtext/x-script.zsh
Comparte este artículo

11 comentarios en “Error al subir ficheros en WordPress: Perdona, por razones de seguridad, este tipo de archivos no está permitido”

  1. Pues a no ser que sea un error de las comillas de este post, lo veo bien. Prueba a poner este código por si acaso es por cómo el post presenta las comillas.

    add_filter('upload_mimes', 'mqw_mas_extensiones');
    function mqw_mas_extensiones ( $existing_mimes=array() ) {
    $existing_mimes['swf'] = 'application/x-shockwave-flash';
    return $existing_mimes;
    }

    Responder
  2. Gracias por el aviso Alberto, es verdad que las comillas salían mal aunque en el artículo original estaban bien, parece que WordPress las mostraba diferentes. Pero lo he solucionando encerrando el código con las etiquetas code y /code, parece que ahora salen perfectamente, y de paso ya me ha servido para saber que debo encerrar los códigos con eso para que no haya transformaciones inesperadas.

    Responder

Deja un comentario

3 × 4 =