Form plugin: MIME type troubles when uploading files

Using the Form plugin, I’m having troubles with uploading files other than images.

When I modify a form page frontmatter using a text editor or the Admin panel like so:

      name: file_upload
      label: 'Add a file'
      type: file
      multiple: false
      destination: 'user/data/files'
      accept: [application/pdf, application/x-pdf, image/png, text/plain]

Grav reformats the list of MIME types like this:

      name: file_upload
      label: 'Add a file'
      type: file
      multiple: false
      destination: 'user/data/files'
      accept:
         - application/pdf
         - application/x-pdf
         - image/png
         - text/plain 

This setting allows me to select only PDF files, PNG format images and text files. So far, so good.
However when I select a text file and submit the form, Grav complains: ‘File “sample.txt” is not an accepted MIME type.’

Examining the POST request with the Firefox Addon HttpFox I can see the MIME type is ‘Content-Type: text/plain’. Still the file is rejected. The same goes for PDF files but PNG files are allowed and saved in the page folder (BTW not in ‘user/data/files’ which exists and is writable).

I’ve tested the upload both on localhost (OSX, PHP Version 5.6.16) and on a shared host (Linux, PHP Version 5.6.15).
Any help is much appreciated.

Noticed and recreated the problem. I’ve pushed a fix, can you apply this and tell me if it works for you? https://github.com/getgrav/grav-plugin-form/pull/33

I’ve tested the fix and can confirm it fixes both issues, that is Grav accepts the MIME types specified and files are saved in the correct folder. Thanks @flaviocopes and @w00fz for this fix.

Ok thanks, will include the fix to the next release.