Skip to content

Instantly share code, notes, and snippets.

@luctraonmilin
Created October 24, 2014 08:39
Show Gist options
  • Save luctraonmilin/05f956efa892b8a9ad97 to your computer and use it in GitHub Desktop.
Save luctraonmilin/05f956efa892b8a9ad97 to your computer and use it in GitHub Desktop.
Custom HTML file select button trick
<html>
<head>
<title></title>
<script type="text/javascript">
function selectFile() {
document.getElementById('file').click();
}
</script>
<style type="text/css">
#select-file {
color: #fff;
background-color: #444;
padding: 4px 8px;
display: inline-block;
border-radius: 4px;
}
#select-file:hover {
background-color: #777;
cursor: pointer;
}
</style>
</head>
<body>
<input type="file" style="display: none;" id="file">
<div id="select-file" onclick="selectFile();">
Select file
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment