ContentType() returns bad type for office templates

Function ContentType in phpfn.php is returning the wrong content type for word templates dotx (and I expect, xltx).

For dotx it returns ‘application/vnd.openxmlformats-officedocument.wordprocessingml.document’, which is the content type for docx. Correct type is ‘application/vnd.openxmlformats-officedocument.wordprocessingml.template’. Actually, this is correctly set in the “MIME_TYPES” array in ewcfg.php, but ContentType() tries to identify the content type from actual file contents over its extension.

This is not a problem using Chrome for instance, but in Firefox it adds .docx when downloading filename (making it docname.dotx.docx), which will cause an error opening in MS Word.

For now, I added this line to the beginning of ContentType():

if ($fn != “”) return MimeContentType($fn);

…maybe this could be corrected in a coming version.

If you’re using v2020, then make sure you have already updated to the latest minor version, and after that, make sure also you have already updated to the latest template from “Tools” → “Update Template”.

How to implement MIME content type?
Like to check content type for word?
And where to put that script ? Server or client script?
Thank you for your help