JSFiddle - React, Tailwind, and code Playground

HTML

<input id="theFiles2" type="file" name="file" multiple="">

JavaScript

$(function(){
    $("#theFiles2").click(function(){
        var $fileUpload = $("input[type='file']");
        
    });  
    
    $("#theFiles2").on("change", function() {
         if($("#theFiles2")[0].files.length > 2) {
          alert("Vous devez télécherger seulement 5 fichiers");
         }
     });
});