Skip to content

Instantly share code, notes, and snippets.

@daohodac
Created October 23, 2014 16:41
Show Gist options
  • Save daohodac/6304a583a3f021282d31 to your computer and use it in GitHub Desktop.
Save daohodac/6304a583a3f021282d31 to your computer and use it in GitHub Desktop.
replace the <input type="text"> with a nice button
<div class='file-input'>
<input type="file" id="theSvgFile" name="theSvgFile" class="hide ie_show" onchange="readURL(this);"/>
<div class="btn btn-default" onclick="$(this).parent('.file-input').find(':file').click();">Upload SVG</div>
<span class="file-display"></span>
<script type="text/javascript">
var readURL = function (input) {
if (input.files && input.files[0]) {
$(input).parent('.file-input').find('.file-display').text(input.files[0].name);
}
}
</script>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment