2

I have modified code based on this tutorial to display uploaded images in an angular project.

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; 
    }
}

This works fine, the only thing is, I also want to check if the file is a video. Is the correct syntax

mimeType.match(/video\/*/)

?

1 Answer 1

2

You are right: https://help.encoding.com/knowledge-base/article/correct-mime-types-for-serving-video-files/

Below you can fine full mime types

Flash           .flv    video/x-flv
MPEG-4          .mp4    video/mp4
iPhone Segment  .ts     video/MP2T
3GP Mobile      .3gp    video/3gpp
QuickTime       .mov    video/quicktime
A/V Interleave  .avi    video/x-msvideo
Windows Media   .wmv    video/x-ms-wmv
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.