Issue
I want the input="file"
to be hidden and style the input="file"
with icon and clicking upon the icon to select image.
.cover_photo {width:100%; height:250px; overflow:hidden; position:relative;}
.cover_photo img {width:100%;}
.upload_btn { position:absolute; top:0; left:0;}
.upload_btn input[type="file"] {display:none;}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<section>
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="cover_photo">
<img class="img-responsive" src="http://underafricanskiessafaris.co.za/wp-content/uploads/2015/02/BG-1.jpg" />
<div class="upload_btn">
<form>
<i id="icon_upload" class="fa fa-camera"></i>
<input type="file" name="cover-photo" id="icon_upload" />
</form>
</div>
</div>
</div>
</div>
</div>
</section>
Solution
I think you want something like this.Place an icon and clicking on the icon, programmatically click the input type file.
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<input type="file" id="file_upload_id" style="display:none">
<label>Upload:</label> <a href="#"><i id="icon_upload" class="fa fa-upload" onclick="_upload()"></i></a>
<script>
function _upload(){
document.getElementById('file_upload_id').click();
}
</script>
Answered By - Ataur Rahman Munna
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.