JSFiddle - React, Tailwind, and code Playground

HTML

<input type='file' name='file' value='file upload' /><br><br>
<input type='submit' value='submit' id='submit'>

JavaScript

(function() {
  var buttonValue = {};
 

  $("#submit").click(function() {
    $("input[type=file]").each(function($i) {
      var name = $(this).attr('name')
      buttonValue[name] = $(this).val();
    });
    console.log(JSON.stringify(buttonValue)); //I am getting my uploaded file fake path like: C:\\fakepath\\test.txt. not giving the clicked button values in json
  });
}())

//how can I get json data for only clicked buttons and uploaded files, as the above code gives all the buttons data if I remove:&& "input[type=file]" otherwise giving only uploaded file if I keep:"input[type=button]" && "input[type=file]" .