javascriptuploadifive

Forbidden File Type docx


I'm testing the uploadifive plugin file upload restrictions and I cannot seem to get it to accept .docx files. In the documentation (http://www.uploadify.com/documentation/uploadifive/filetype/) I have followed the instructions (bar a small mistake - the pipe "|" character does not work) and have used the media types it refers to (http://www.iana.org/assignments/media-types/media-types.xhtml). No other file type seems to be causing a problem e.g. .doc, .xlsx.

Is there a solution for this, I have checked multiple sources and the mime type (application/vnd.openxmlformats-officedocument.wordprocessingml.document) is correct as far as i can tell?

<h1>UploadiFive Demo</h1>
<form>
    <div id="queue"></div>
    <input id="file_upload" name="file_upload" type="file" multiple="true">
    <a style="position: relative; top: 8px;" href="javascript:$('#file_upload').uploadifive('upload')">Upload Files</a>
</form>

<script type="text/javascript">
    $(function() {
        $('#file_upload').uploadifive({
            'auto'             : false,
            'checkScript'      : 'check-exists.php',
            'queueID'          : 'queue',
            'uploadScript'     : 'uploadifive.php',
            'fileType' : ['application\/msword', 'application\/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application\/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml','application\/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
            'onUploadComplete' : function(file, data) { console.log(data); },
            'onError' : function(errorType)
                        {
                            alert('Error: ' + errorType);
                        },
        });
    });
</script>

Solution

  • The issue was with Firefox assigning the MIME type "application/vnd.ms-word.document.12" to the file instead of "application/vnd.openxmlformats-officedocument.wordprocessingml.document" to .docx files. Chrome and presumably others use the correct one.

    This post (How to check file MIME type with javascript before upload?) proved helpful to see how the browser is treating it.