HTML
<section id="uploadImage"><input type="file" name="fileToUpload"id="fileToUpload">
<label for="fileToUpload" id="uploadLable">Choose Image To Upload</label>
</section>
<button class="btnR"type="submit" name="submit">Uplaod</button>
CSS
input[type="file"]{
opacity: 0;
display: none;
}
#uploadLable{
width: 100%;
background-color: rgb(245,245,245);
color: rgb(80,80,80);
padding: 20px;
font-size: 16px;
}
.btnR{
color: white;
background-color: cornflowerblue;
min-width: 100px;
padding: 15px;
transition: 0.5s;
}
.btnR:hover{
transform: rotate(10deg);
}
香草 javascript
document.getElementById('fileToUpload').onchange=function() {fileName()};
function fileName(){
var x=document.getElementById('fileToUpload').value;
document.getElementById('uploadLable').innerHTML=x;
}