I have customized the code inspired by this particular guide in order to showcase uploaded images within an angular application.
public uploadFile = (files) => {
if (files.length === 0) {
return;
}
var mimeType = files[0].type;
if (mimeType.match(/image\/*/) == null) {
this.message = "Only images are supported.";
return;
}
var reader = new FileReader();
reader.readAsDataURL(files[0]);
reader.onload = (_event) => {
this.imgURL = reader.result;
}
}
It's working smoothly, but I also aim to verify if the uploaded file is a video. Should the correct syntax be
mimeType.match(/video\/*/)
?