我正在使用具有文件类型限制的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();
};
有人知道如何使它工作吗?
最佳答案
请检查this thread,allowedFileTypes实际上不是文件扩展名,它支持以下文件类型:
应用
图片
视频
音讯
pdf格式
压缩
文件
xls
ppt
尝试将image
添加到允许的文件类型列表。