Allow upload mimetypes (file type extension)

Recently I wanted to upload some configuration backup-files of my FRITZ!Box to my internal DokuWiki. But if I’ve tried to upload the .export – files I did get the error message “Invalid file”:

Invalid file type error message DokuWiki (mimetypes)
DokuWiki: Invalid file error message

The solution is to add the file extension .export (mimetype text/plain) to the list of allowed mimetypes. DokuWiki uses the file conf/mime.conf  to determine whether a file type or extension is allowed or not. This file contains all valid mimetypes in the form:

file-extension . . . . mimetype

For example:

jpg     image/jpeg
jpeg    image/jpeg
gif     image/gif
png     image/png
ico     image/

mp3     audio/mpeg
ogg     audio/ogg
wav     audio/wav
webm    video/webm
ogv     video/ogg
mp4     video/mp4

tgz     !application/octet-stream
tar     !application/x-gtar
gz      !application/octet-stream
bz2     !application/octet-stream
zip     !application/zip
rar     !application/rar
7z      !application/x-7z-compressed

Because we want to keep our DokuWiki installation updateable, it is a bad idea to change the original file directly. Instead DokuWiki offers the possibility to crate an individual mimetype configuration file named conf/mime.local.conf to define additional mimetypes.

That’s why I created this configuration file and just added one line for my .export file-extension and the corresponding mimetype text/plain:

# Fritzbox configuration  exports
export     !text/plain

The exclamation mark as a mimetype prefix only tells DokuWiki to force the browser to deliver files with the respective extension as a download although the browser might have a plugin to deal with such mimetypes/files.

Custom file icons for mimetypes

Additionally you can add a 16 x 16 pixel PNG or GIF – file to the lib/images/fileicons/ directory named after the file extension (in my case export.png). After that you have to clear the cache (go to YOURWIKIDOMAIN/?do=admin&page=config and save the configuration once -> save button at the bottom of the page or just do a $> touch conf/local.php on a bash / shell).

Further information

For more information about DokuWiki and its mime type configuration have a look at the corresponding DokuWiki-Documentation. To get more information about mimetyes you can refer to the Wikipedia articles about MIME and Internet media types.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.