Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

3.1.6 + MIMEValidator - Can't upload docx (Or any office 2007 file types)


Go to End


5 Posts   1404 Views

Avatar
Peavers

Community Member, 20 Posts

7 October 2014 at 3:36pm

Edited: 07/10/2014 3:42pm

Since upgrading to 3.1.6 and installing the MIME validator I'm unable to upload office 2007 files via any method...

If I remove the MIME validator, uploads work as expected. I've added the following to my config file and still no luck

Injector:
  Upload_Validator:
    class: MimeUploadValidator
File:
  allowed_extensions:
    - 'docx'
HTTP:
  MimeTypes:
   'docx' : 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'

Is there anything else I should be doing?

Avatar
martimiz

Forum Moderator, 1391 Posts

9 October 2014 at 3:44am

The module uses php finfo, and googling 'finfo' and 'docx ' comes up with lots of issues concerning MS 2007 files, saying that for these files the mime type is actually application/zip. Haven't checked this myself, but who knows :)

Avatar
Peavers

Community Member, 20 Posts

9 October 2014 at 8:23am

Thanks for that tip, it pointed me in the right direction. application/zip as you and many others on Stack Overflow suggested didn't work. So after running the following on some test files

<?php
$finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
foreach (glob("*") as $filename) {
    echo finfo_file($finfo, $filename) . "\n";
}
finfo_close($finfo);
?>

The result was application/msword

Adding this to the config allows docx to be uploaded..

Avatar
martimiz

Forum Moderator, 1391 Posts

10 October 2014 at 1:40am

Great, glad I could at least be of some help :).

I saw you created an issue on https://github.com/silverstripe-labs/silverstripe-mimevalidator/issues. Maybe a good idea to share it there as well...

Avatar
Peavers

Community Member, 20 Posts

10 October 2014 at 7:40am

Agreed, but wanted to sort the other formats first. Seems xlsx isn't playing nicely regardless of what I set for it.