在 html5 中使用 FileReaderService 时获取上传文件的文件类型

get file type of uploaded file when FileReaderService is used in html5

我正在尝试检测上传文档的文件类型。为此,我创建了一个 "FileReaderService" 的实例。我正在做这样的事情:

var reader = FileReaderService.createReaderInstance(), 文件数据 = angular.copy(新文件);

      reader.onload = function (event) {
        scope.loaded(event, scope.files[index]);
      }.bind(scope);

      fileData.file = file;
      fileData.fileType = scope.fileType(fileData);

这适用于 pdf 和图像,但对于 docx、sheet 和 pptx。这不能正常工作 请帮我解决这个问题。

我已经解决了。我比较文件类型的地方我在那里犯了一个错误: 以前使用的是doc,现在使用的是docx。 现在docx、pptx和styles的文件类型如下:

sheet: vnd.openxmlformats-officedocument.spreadsheetml.sheet
docx: vnd.openxmlformats-officedocument.wordprocessingml.document
pptx: vnd.openxmlformats-officedocument.presentationml.presentation