The file to be validated.
true
if the file type is 'image/jpeg' or 'image/png', otherwise false
.
const jpgFile = new File([], "image.jpg", { type: "image/jpeg" });
console.log(isJpgOrPng(jpgFile)); // true
const pngFile = new File([], "image.png", { type: "image/png" });
console.log(isJpgOrPng(pngFile)); // true
const pdfFile = new File([], "document.pdf", { type: "application/pdf" });
console.log(isJpgOrPng(pdfFile)); // false
Checks if the given file is a JPG or PNG image.
This function is useful for file type validation during image uploads.