I would like to use Devextreme angular's file uploader component to parse some data in javascript, but I can't seem to find a way, not to post data first to server.
I can parse data in javascript using xlsx library and html input
tag and its change
event:
<input type='file' (change)="onSelectFile($event)" multiple>
and .ts:
onSelectFile(event) {
if (event.target.files && event.target.files[0]) {
const filesAmount = event.target.files.length;
for (let i = 0; i < filesAmount; i++) {
const reader = new FileReader();
reader.onload = (event:any) => {
const bstr: string = event.target.result;
const data = <any[]>this.excelService.importFromFile(bstr);
// data is ready
};
reader.readAsBinaryString(event.target.files[i]);
}
}
}
Can I prevent file-uploader to upload data to server, so I can parse it first on client side? I would like to use this component, because it provides validations and correct styling out of the box.
Thanks
you can try.
<dx-file-uploader
selectButtonText="Upload File"
labelText="or Drop here"
accept="*"
uploadMode="useForm"
[allowCanceling]="true"
(change)="handleInputChange($event)"
></dx-file-uploader>