Skip to content

Instantly share code, notes, and snippets.

View r1d3rzz's full-sized avatar
💻
Working from home

MyintThwayKhine r1d3rzz

💻
Working from home
View GitHub Profile
@r1d3rzz
r1d3rzz / fileTypeFilter.js
Created June 24, 2024 05:34
File Type Filter WIth JS
function checkFileExtension(file, ...allowFileTypes) {
const allowedExtensions = allowFileTypes; // List allowed extensions
const fileExtension = file.name.split('.').pop().toLowerCase();
return allowedExtensions.includes(fileExtension);
}
function checkContentType(file) {
const allowedTypes = ['image/jpeg', 'image/png', 'application/zip', 'application/pdf']; // List allowed MIME types
return allowedTypes.includes(file.type);
}