Skip to content

Instantly share code, notes, and snippets.

@philippeantoine
Created May 12, 2012 13:24
Show Gist options
  • Save philippeantoine/2666487 to your computer and use it in GitHub Desktop.
Save philippeantoine/2666487 to your computer and use it in GitHub Desktop.
hidden input file
<!doctype html><head><meta charset="UTF-8">
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet">
</head><body>
<form name="f">
<!-- when I click on the a link, I get the file input popup -->
<p><a id="ok" class="btn span1"><i class="icon-plus-sign"></i> PASS</a>
<input type="file" name="fileok">
<script>
window.ok.onclick = function(){ document.f.fileok.click(); }
</script>
<!-- when the input is hidden, I get nothing... -->
<p><a id="ko" class="btn span1"><i class="icon-plus-sign"></i> FAIL</a>
<input type="file" name="fileko" style="display:none"><!-- I don't want to display this input -->
<script>
window.ko.onclick = function(){ document.f.fileko.click(); }
</script>
</form></body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment