首页 > 解决方案 > DevExtreme 文件上传 - 获取组件中的文件内容

问题描述

我想使用 DevExtreme dxFileUploader 上传文件并在组件中处理其内容(不使用服务 url)。

我正在使用 Angular 8.2.2 和 DevExtreme 19.1。我尝试使用 onValueChange 事件处理文件,但我只获取文件的属性(文件名、文件大小等)而不是内容本身。

app.component.html:

<dx-file-uploader #fileUploader (onValueChanged)="processFile($event)"
[multiple]="false" accept="*" [(value)]="value" uploadMode="useButtons">
</dx-file-uploader>

app.component.ts:

public value: any[] = [];

processFile(e) {
   console.log(this.value); // shows only file attributes
}

有没有办法从 dxFileUploader 控件访问文件内容?

标签: angulardevextreme

解决方案


processFile(e) {
    console.log(e.value[0]);
}

推荐阅读