JSFiddle - React, Tailwind, and code Playground

by kiokotzu

HTML

<div class="clearfix file">
    <input type="file" id="test" class="file">
    <input type="text" class="valorfile">
    <div class="button-group"> 
      <a href="#" id="browse" class="adjuntar btn-verde" class="">Examinar</a>
    </div>
</div>

CSS

.file {
  position: relative;
}
.file input[type="file"] {
  display: none;
}
.file input[type="text"] {
  padding-right: 105px;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
.file .adjuntar {
  position: absolute;
  right: 0px;
  top: 3px;
  text-decoration: none;
  width: 100px;
  font-size: 10px;
  height: 32px;
  line-height: 32px;
  padding: 0;    
  background:crimson;
  color:#fff;
}

JavaScript

var file,texto;
  /* FILE */
  $(".adjuntar").click(function () {
    file = $(this).parents().eq(1).children('input[type=file].file');
    texto = $(this).parents().eq(1).children('.valorfile');

    $(file).change(function () {
      if(file.attr("multiple") == "multiple"){
        var names = [];
         for (var i = 0; i < $(this).get(0).files.length; ++i) {
          names.push($(this).get(0).files[i].name);
        }
        texto.val(names);
      }else{
       texto.val($(this).val());
      }
    });
    $(file).click();
    return false;
  });