Hello. On my private wiki, I have enabled the uploading of Microsoft Outlook 2016 Email Templates (.oft) using $wgFileExtensions. But when uploading an oft file, I'm faced with the error File extension ".oft" does not match the detected MIME type of the file (application/sla)
. Is there a way to fix or overcome this? Or perhaps a way to skip MIME checks for oft files? It may be worth mentioning that the .oft email template contains a PDF attachment. Thanks for any help.
Topic on Project:Support desk
You can disable the verification by setting $wgVerifyMimeType
to false. You can also extend the allowed types by using $wgMimeTypeFile
.
Thanks for the reply @Ammarpad. I would like to disable MIME type check only for .oft
files. Is that possible? If so, would you be able to help me with the code for that please?
I am not sure, but on quick look it seems not possible**. You should either opt for verification or not. You can of course also add the type to the file for $wgMimeTypeFile
so that the verification will pass. For me, that seems more effective and simple thing to do.
**By 'not possible' I mean there's no easy way to do this, since there's no hook that trivially allows that, and I don't think you'd want maintain a hacked local copy of UploadBase.php.
Oh okay. How do I add the type to the file?
After reading further, I finally found a non-hacky solution to allow uploads of .oft
files:
- If not already done, add
.oft
files to the list of supported extensions ($wgFileExtensions
) - In MediaWiki 1.34.2, edit
/includes/libs/mime/mime.types
and modifyapplication/sla stl
toapplication/sla stl oft
. (As far as I know, this directory is changed for 1.35+)
That's it. Without lowering and amending security, I can now upload .oft
files.
Hope this helps others struggling with this.