Restricting File Upload to .xlsx Format

if (fileName && fileName.toLowerCase().endsWith(‘.xlsx’)) {

  // Proceed with file upload

} else {

  // Inform the user about the error

  Response.write({ output: ‘There was an error uploading the file. Only Excel files are accepted. Please try again using an Excel file.’ });

  return;

}

Leave a comment

Your email address will not be published. Required fields are marked *