File input trigger w/ jquery

clicking on any button will trigger FILE input

by ajinkyax

HTML

<form id="test_form">
  <input type="file" id="test">
  <button>Upload</button>
      <span>No file selected</span>
</form>

CSS

input{position:absolute; top:-100px;}

JavaScript

$("button").click(function() {
    $("#test").click();
})

$('#test').change(function() {
    var fileVal = $('#test').val();
    $('span').text(fileVal);
    //$('#test_form').submit();
});