I'm experiencing a challenge with displaying multiple images and videos in my Angular application. To differentiate between the two types of files, I use the "format" variable.
export class AppComponent {
urls;
format;
onSelectFile(event) {
const files = event.target.files;
if (files) {
for (const file of files) {
if (file.type.indexOf("image") > -1) {
this.format = "image";
} else if (file.type.indexOf("video") > -1) {
this.format = "video";
}
const reader = new FileReader();
reader.onload = (e: any) => {
this.urls.push(e.target.result);
};
reader.readAsDataURL(file);
}
}
}
}