i am using ngx-file-upload for image uploading and sending it as base64 with my formvalue. it works for one image but how can i make it work for multiple images?
.ts
send() {
// if (this.createEstimation.valid) {
let value = this.createEstimation.value;
const selectedFile = <File>value.files;
const file = selectedFile[0];
const fileName = file.name;
const fileExtension = file.name.split('.').pop().toLowerCase();
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => {
const image = reader.result as any;
var strImage = image.split("base64,")[1].substring(4);
//final data
this.finalData = {
client: {
firstName: value.firstName.split(' ').slice(0, -1).join(' '),
lastName: value.firstName.split(' ').slice(-1).join(' '),
},
images: [
{
fileName: fileName,
content: strImage
}
],
}
console.log(this.finalData);
}
}
}
fileName&contentproperties. Then finaaly attach that array to your finalData