Created
July 1, 2018 02:04
-
-
Save loveyunk/34b6c2f28bb472f219192e310c1d3f1e to your computer and use it in GitHub Desktop.
upload.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
<style> | |
#custom-button { | |
padding: 10px; | |
color: #fff; | |
background-color: #009578; | |
border: 1px solid #000; | |
border-radius: 5px; | |
cursor: pointer; | |
} | |
#custom-button:hover { | |
background-color: #00b28f; | |
} | |
#custom-text { | |
margin-left: 10px; | |
font-family: sans-serif; | |
color: #aaa; | |
} | |
</style> | |
</head> | |
<body> | |
<input type="file" id="real-file" hidden /> | |
<button type="button" id="custom-button">CHOOSE A FILE</button> | |
<span id="custom-text">No file choose, yet</span> | |
<script> | |
const realFileBtn = document.getElementById('real-file'); | |
const customBtn = document.getElementById('custom-button'); | |
const customText = document.getElementById('custom-text'); | |
customBtn.addEventListener('click', function () { | |
realFileBtn.click(); | |
}, false); | |
realFileBtn.addEventListener('change', function () { | |
if (realFileBtn.value) { | |
customText.innerHTML = realFileBtn.value; | |
} else { | |
customText.innerHTML = 'No file chosen, yet.'; | |
} | |
}, false); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment