"button upload and preview"
Bootstrap 4.1.1 Snippet by mrpcyber

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="row"> <div class="col-md-12"> <h1>JS from <a href="https://bootsnipp.com/snippets/qr6rB">credit akshayptdr4</a></h1><br> <h1>I make Button from <a href="https://www.abeautifulsite.net/whipping-file-inputs-into-shape-with-bootstrap-3">abeautifulsite</a></h1><br> </div> <div class="col-md-12 uploadfrm"> <p><span class="btn btn-primary btn-file"> browse file <input type="file" onchange="readURL(this);"> </span></p> </div> <div class="preview"> <img id="blah" src="" alt="" class="img-thumbnail border-0"> </div> </div> </div>
.btn-file { position: relative; overflow: hidden; } .btn-file input[type=file] { position: absolute; top: 0; right: 0; min-width: 100%; min-height: 100%; font-size: 100px; text-align: right; filter: alpha(opacity=0); opacity: 0; outline: none; background: white; cursor: inherit; display: block; } img{ width:400px; height:400px; }
function readURL(input) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function (e) { $('#blah') .attr('src', e.target.result); }; reader.readAsDataURL(input.files[0]); } }

Related: See More


Questions / Comments: