Last active
October 17, 2020 04:42
-
-
Save juananruiz/8841542 to your computer and use it in GitHub Desktop.
Botón bonito para subir ficheros a bootstrap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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