"image uploader"
Bootstrap 3.3.0 Snippet by mdburhani52

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/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"> <h2>Create your snippet's HTML, CSS and Javascript in the editor tabs</h2> <div class="col-sm-3 col-xs-12"> <div class="comp-logo"> </div> <div class="up-btn" id="upload">Upload </div> <input type="file" name="" id="my-prf" style="display: none;"> </div> </div> </div>
.comp-logo { width: 100%; height: auto; min-height: 150px; max-height: 150px; background-color: #efefef; margin-top: 15px; overflow-y: hidden; } .up-btn:hover { background-color: #0b4d73; } .up-btn { width: 100%; height: 33px; background: #0b669a; color: #fff; border: none; border-radius: 0px 0px 10px 10px; transition: all ease 01s; display: inline-block; vertical-align: middle; line-height: 33px; text-align: center; cursor: pointer; } .comp-logo { background-size:cover; background-position:center; }
$('#upload').on('click', function() { $('#my-prf').trigger('click'); }); $("#my-prf").change(function () { if (this.files && this.files[0]) { var reader = new FileReader(); reader.onload = imageIsLoaded; reader.readAsDataURL(this.files[0]); } }); function imageIsLoaded(e) { // $('.abc').attr("src", event.target.result); $('.comp-logo').css('background', 'url("' + event.target.result + '")'); };

Related: See More


Questions / Comments: