JSFiddle - React, Tailwind, and code Playground

by gregorypratt

HTML

<input type="button" id="get_file" value="Grab file">
<input type="file" id="my_file">
<div id="customfileupload">Select a file</div>

CSS

#my_file {
    display: none;
}

#get_file {
    background: #f9f9f9;
    border: 1px solid #88c;
    padding: 10px;
    border-radius: 5px;
    margin: 10px;
    cursor: pointer;
}
#customfileupload
{
    display: inline;
    background-color: #fff;
    font-size: 14px;
    padding: 10px 30px 10px 10px;
    width: 250px;
    border: 1px solid #999;
    box-shadow: inset 1px 1px 5px #ccc;
    -webkit-box-shadow: inset 1px 1px 5px #ccc;
    -moz-box-shadow: inset 0px 0px 4px #ccc;
    -ms-box-shadow: inset 0px 0px 4px #ccc;
    -o-box-shadow: inset 0px 0px 4px #ccc;
    z-index: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

JavaScript

document.getElementById('get_file').onclick = function() {
    document.getElementById('my_file').click();
};

$('input[type=file]').change(function (e) {
    $('#customfileupload').html($(this).val());
});