禁止的文件类型docx

时间:2016-04-11 11:16:40

标签: javascript uploadifive

我正在测试uploadifive插件文件上传限制,我似乎无法接受.docx文件。在文档(http://www.uploadify.com/documentation/uploadifive/filetype/)中,我遵循了指示(禁止一个小错误 - 管道" |"字符不起作用)并使用了它引用的媒体类型({{3 }})。没有其他文件类型似乎导致问题,例如.doc,.xlsx。

有没有解决方法,我检查了多个来源,mime类型(application / vnd.openxmlformats-officedocument.wordprocessingml.document)是正确的,我可以告诉你?

<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>

1 个答案:

答案 0 :(得分:0)

问题在于Firefox分配MIME类型&#34; application / vnd.ms-word.document.12&#34;到文件而不是&#34; application / vnd.openxmlformats-officedocument.wordprocessingml.document&#34;到.docx文件。 Chrome和其他人可能会使用正确的。

这篇文章(How to check file MIME type with javascript before upload?)证明有助于了解浏览器如何处理它。

相关问题