JSFiddle - React, Tailwind, and code Playground
HTML
<div class="fileUpload">
<input class="upload" type="file" name="upload">
<span class="uploadValue">Nichts ausgewählt</span>
</div>
CSS
/* Einschränken des sichtbaren Ausschnitts */
.upload {
position: absolute;
clip: rect(0px 76px 27px 0px);
cursor: pointer;
}
/* Upload Button ausblenden */
.upload::-webkit-file-upload-button {
visibility: hidden;
opacity: 0;
}
.upload:before {
/* Beschriftung des Buttons mit CSS content */
content: 'Upload';
/* Aussehen des Buttons */
display: inline-block;
width: 50px;
padding: 0 12px;
font-size: 12px;
height: 25px;
line-height: 25px;
color: #333333;
text-align: center;
cursor: pointer;
background-color: #f5f5f5;
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
border: 1px solid #e6e6e6;
border-bottom-color: #b3b3b3;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;*/
}
.fileUpload {
margin: 20px;
}
.uploadValue {
margin: 0 0 0 80px;
font-size: 12px;
height: 25px;
line-height: 25px;
}
}
JavaScript
$('.upload').on('change',function(){
var fileValue = ($(this).val() !== "") ? '...' + $(this).val().substr(-15) : 'Nichts ausgewählt';
$('.uploadValue').html('').append(fileValue);
});