Is there a way to know if the file extension is an image?
i got this.
image/png
Already try with
var imageReg = /\.(gif|jpg|jpeg|tiff|png)$/i;
string = "image/png"
imageReg.test(string)
But this return false;
Put dot and /
inside a character class so that it would match .png
or /png
strings.
var imageReg = /[\/.](gif|jpg|jpeg|tiff|png)$/i;
Your regex would return true
if there is a dot before png
but here there exists a forward slash, so it fails.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With