Skip to content

Instantly share code, notes, and snippets.

@0xPr0xy
Created November 12, 2012 17:40
Show Gist options
  • Select an option

  • Save 0xPr0xy/4060754 to your computer and use it in GitHub Desktop.

Select an option

Save 0xPr0xy/4060754 to your computer and use it in GitHub Desktop.
File Upload field without button, only text
<html>
<head>
<style>
#file{
display:none;
}
</style>
</head>
<body>
<div id="file">Choose File</div>
<input type="file" name="file"></input>
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
var wrapper = $('<div/>').css({height:0,width:0,'overflow':'hidden'});
var fileInput = $(':file').wrap(wrapper);
fileInput.change(function(){
$this = $(this);
$('#file').text($this.val());
})
$('#file').click(function(){
fileInput.click();
}).show();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment