4

I can no longer upload docx or odt files to use as templates. Not sure when it happened but I'm running 5.6.0. I had uploaded files previously and even when downloading that same file and trying to upload again I get the error. Is it possibly a directory permissions issue? Confused... Not sure where to. Turning on debugging give no additional information. Thanks.

Attached is a screen shot of when I try to save and the enter image description here

and a Link to the bare .docx (stripped tokens)

message template

| improve this question | | | | |
  • Update to the latest release and see if that cures the problem. – Tony Horrocks Nov 3 '18 at 21:04
  • 2
    There is an attempt to edit this post from another account with the same username. If you created a duplicate account (accidentally or because you lost access to the original one), please see civicrm.stackexchange.com/help/merging-accounts about merging them. – choster Dec 13 '18 at 4:57
1

Thank you for adding the screenshot - it makes the issue much clearer. I actually haven't used this feature before and it seems to be undocumented :( That said, I was able to use it successfully on my local install.

While this might be a bug you're seeing, I looked at the code and am suspecting a MIME misconfiguration in the website software settings. To help track down which it is, I recommend editing the file at <civiroot>/CRM/Admin/Form/MessageTemplates.php.

Find this line: $errors['file_id'] = ts('Invalid document file format');

Replace it with: $errors['file_id'] = 'MIME type: ' . $files['file_id']['type'];

The acceptable values are:

  • docx: application/vnd.openxmlformats-officedocument.wordprocessingml.document
  • odt: application/vnd.oasis.opendocument.text

If you're getting a different value, hopefully it will provide a helpful clue as to the problem. If not, please edit the question again to show the error you're getting.

| improve this answer | | | | |
  • I just successfully uploaded your document as a message template. So I would definitely check for MIME type issues with your webserver! – Jon G - Megaphone Tech Dec 20 '18 at 5:57
  • Thanks @Jon G, I'm still having trouble with templates. I've edited MessageTemplates.php as per your suggestions above and I'm still getting an error. "MIME type: application/octet-stream" My mime types are set up exactly as you describe above. Any suggestions? – Stephen Sloan Jan 28 '19 at 17:09
1

Based on your comment on my other answer, the issue is that your web browser is setting the MIME type incorrectly to application/octet-stream, which basically means "unknown file type". While detailed answers exist on how browsers determine MIME type, the short answer is to see if you can isolate the problem to a particular operating system, browser, etc.

As a fallback, you can simply delete the line I suggested you modify in my other answer - it's very likely this will cause things to start working. However, this isn't a great long-term answer, if for no other reason than you'll need to apply the fix every time you upgrade.

| improve this answer | | | | |
  • Thanks @Jon G, I can confirm that the same problem occurs on both Windows and ChromeOS using the Chrome browser. I'll have to load up another browser to see if it is browser based. – Stephen Sloan Jan 28 '19 at 23:12
  • Tried Firefox, same result. I'll try deleting that line. – Stephen Sloan Jan 29 '19 at 1:14
  • OK, was able to "upload" using FF under Linux. No joy though, the contents of the file were not added to the template. – Stephen Sloan Jan 29 '19 at 1:37
  • 1
    OK, so I had to update the registry entry for docx to add Content Type = application/vnd.openxmlformats-officedocument.wordprocessingml.document and now it works. – Stephen Sloan Jan 29 '19 at 2:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.