Hi I want to upload multiple file and send them to a server: using reactive form: I define this in the appropriate class:
this.attachmentsForm = this.formBuilder.group({
attachmentName: ['']
});
in the template html :
<form [formGroup]="attachmentsForm">
<ion-item>
<ion-label floating>
Attachment Name
</ion-label>
<ion-input type="text" formControlName="attachmentName"></ion-input>
</ion-item>
<input class="form-control" #fileInput type='file' (change)="fileChanged($event)">
</form>
In this class I used this function :
fileChanged(event) {
if (event.target.files && event.target.files[0]) {
if (event.target.files[0].size > 512000) {
this.fileValid = false;
let toast = this.toastCtrl.create({
message: 'the file size more than 500kb',
duration: 3000
});
toast.present();
} else {
this.fileValid = true;
}
}
}
So how can I get the data of the attachments :(Base64 or if there another solution) thanks in advance