JSFiddle - React, Tailwind, and code Playground

HTML

<input type="file"/>

JavaScript

$(document).ready(function () {
$('input[type=file]').change(function () {
var val = $(this).val().toLowerCase();
var regex = new RegExp("(.*?)\.(jpg|jpeg|gif)$");
if(!(regex.test(val))) {
$(this).val('');
alert('Unsupported file');
} 
if (this.files[0].size > 50000 || this.files[0].size > 50000)
    {
        //reset file upload control
       $(this).val('');
       //show an alert to the user
       alert('Allowed file size exceeded 50KB');


    }
}); });