HTML:
<div>
<input
type ="file"
(change)="selectFiles($event)"
multiple="multiple" />
</div>
Function to handle the change event
selectFiles(event) {
const reader = new FileReader();
if (event.target.files && event.target.files.length) {
const files = Array.from(event.target.files);
for (let i = 0; i < files.length; i++) {
reader.readAsDataURL(files[i]);
reader.onload = () => {
this.myModel.get('propertyName').setValue({
fileName: files[i].name,
fileContent: reader.result
});
};
}
}
}
I need to retrieve content from multiple selected files in one request, how can I achieve that?