JSFiddle - React, Tailwind, and code Playground

by VansFannel

HTML

<div class="file-upload btn btn-primary">
							<span>Upload</span>
							<input id="uploadBtn" class="upload" type="file">
						</div>
						<p style="display:inline">
							<input id="uploadFile" type="text" placeholder="Choose File" disabled="disabled">
						</p>
						<p><input type="submit" value="Cargar c&oacute;digos" /></p>

CSS

/* 

	As this stylesheet is lazy loaded these styles only apply if JavaScript is enabled

*/	

input[type=submit]              {
  font-size:18px;
  padding:10px 10px 10px 5px;
  width:200px;
  border:none;
  border-bottom:1px solid #757575;
}

.file-upload {
	overflow: hidden;
	display: inline-block;
	position: relative;	
	vertical-align: top;
	text-align: center;

	/* Cosmetics */
	color: #fff;
	border: 2px solid #2FA2FF;
	background: #6FBEFF;

	/* Nice if your browser can do it */
	-moz-border-radius: 8px;
	-webkit-border-radius: 8px;
	border-radius: 8px;
	text-shadow: #000 1px 1px 4px;
	}
	
.file-upload:hover { 
	background: #2FA2FF; 
	}

.file-upload.focus { 
	outline: 2px solid yellow;
	}

.file-upload input {
	position: absolute;
	top: 0;
	left: 0;
	margin: 0;
	font-size: 70px;

	/* Loses tab index in webkit if width is set to 0 */
	opacity: 0;
	filter: alpha(opacity=0);
	}

.file-upload strong { 
	font: normal 1.75em arial,sans-serif; 
	}	
	
.file-upload span {
	position: absolute;
	top: 0;
	left: 0;
	display: inline-block;

	/* Adjust button text vertical alignment */
	padding-top: .45em;
	}

/* Adjust the button size */	
.file-upload { height: 3em; }
.file-upload,
.file-upload span {	width: 14em; }	

.file-upload-status {
	margin-left: 10px;
	vertical-align: middle;
	padding: 7px 11px;
	font-weight: bold;	
	font-size: 16px;
	color: #888;
	background: #f8f8f8;
	border: 3px solid #ddd;
	}

JavaScript

$('input[type="text"]')
        // event handler
        .keyup(resizeInput)
        // resize on page load
        .each(resizeInput);


function resizeInput() {
    $(this).attr('size', $(this).val().length);
}

document.getElementById("uploadBtn").onchange = function () {
    document.getElementById("uploadFile").value = this.value;
    $("#uploadFile").attr('size', $("#uploadFile").val().length);
};