Skip to content
Advertisement

Js or jquery file.type.match for jpg and png only

How can I limit the mimetype for only png and jpg using file.type.match

below is my code

JavaScript

Advertisement

Answer

from your question it sounds like you don’t want to do something like:

JavaScript

You can make an array of acceptable extensions and loop through them like:

JavaScript

See this fiddle for a test.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement