Skip to content

Instantly share code, notes, and snippets.

@juananruiz
Last active October 17, 2020 04:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juananruiz/8841542 to your computer and use it in GitHub Desktop.
Save juananruiz/8841542 to your computer and use it in GitHub Desktop.
Botón bonito para subir ficheros a bootstrap
<label class="control-label" for="fichero1">Añadir nuevo fichero</label>
<div class="controls">
<input id="fichero1" type="file" style="display:none" name="fichero1">
<div class="input-append">
<input id="falso1" class="input-xlarge" type="text">
<a class="btn btn-file"><i class="fa fa-folder-open-o"></i> Seleccionar</a>
</div>
</div>
<script type="text/javascript">
// http://duckranger.com/2012/06/pretty-file-input-field-in-bootstrap/
// Cuando se pulsa el falso manda el click al autentico
$('.btn-file').on('click', function(){
$(this).parent().prev().click();
});
// Cuando el autentico cambia hace cambiar al falso
$('input[type=file]').on('change', function(e){
$(this).next().find('input').val($(this).val());
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment