Angular ng2-file-upload 输入文件过滤器不适用于 Internet Explorer 中的 PNG

mah*_*nim 0 javascript internet-explorer ng2-file-upload angular

我正在使用 ng2-file-upload 中的带有文件类型限制的文件上传器。但是,每次我使用 Internet Explorer 11 选择 png 文件时,它都不会添加到队列中。所有其他允许的文件类型均有效。这是带有文件选项的代码:

let uploadOptions: FileUploaderOptions;
if (navigator.userAgent.match(/Trident.*rv\:11\./)) {
  uploadOptions = {
    url: uploadUrl,
    allowedFileType: ['xls', 'xlsx', 'doc', 'docx', 'pdf', 'gif', 'jpg', 'jpeg', 'png', 'odt', 'txt', 'ods'],
    maxFileSize: 10 * 1024 * 1024
  };
} else {
  uploadOptions = {
    url: uploadUrl,
    allowedMimeType: ['application/pdf',
      'application/vnd.ms-excel',
      'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
      'application/msword',
      'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
      'application/vnd.oasis.opendocument.text',
      'application/vnd.oasis.opendocument.spreadsheet',
      'image/gif',
      'image/jpeg',
      'image/png'
    ],
    maxFileSize: 10 * 1024 * 1024
  };

}

this.uploader = new FileUploader(uploadOptions);
this.uploader.onCompleteAll = () => {
  this.editStateService.documentAdded('player', 'document');
  this.documentListUpdated.emit();
  this.uploader.clearQueue();
};
Run Code Online (Sandbox Code Playgroud)

有人知道如何让它工作吗?

Zhi*_* Lv 5

请检查此线程, allowedFileTypes 实际上不是文件扩展名,它支持以下文件类型:

  • 应用
  • 图像
  • 视频
  • 声音的
  • pdf
  • 压缩
  • 文档
  • .xls
  • PPT

尝试添加image到 allowedFileTypes 列表中。