check for a file size in javascript

index.tsx
// Define a function to check the size of a file
function checkFileSize(file) {
    return file.size;
}

// Usage
const fileInput = document.getElementById('fileInput'); // Assuming you have an input element of type 'file' in your HTML
fileInput.addEventListener('change', function() {
    const file = fileInput.files[0];
    console.log(checkFileSize(file)); // Display the file size in bytes
});
399 chars
12 lines

related categories

gistlibby LogSnag