Created
May 5, 2016 23:08
-
-
Save talha08/2762111e928a6751d57c38eebb96c635 to your computer and use it in GitHub Desktop.
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
............................................ | |
Css | |
............................................ | |
fieldset { | |
border:0; | |
margin-bottom:20px; | |
} | |
input { | |
display:block; | |
} | |
img.preview { | |
width:200px; | |
height:auto; | |
clear:both; | |
margin:10px 0; | |
} | |
.................................... | |
Js | |
.................................... | |
/** | |
* Created by talha on 5/6/2016. | |
*/ | |
var loadFile = function(event) { | |
oldimg = $('.preview').attr('src'); | |
var preview = document.getElementById('preview'); | |
preview.src = URL.createObjectURL(event.target.files[0]); | |
newimg = preview.src; | |
if(newimg.indexOf('/null') > -1) { | |
preview.src = oldimg; | |
} | |
}; | |
//Dummy button :p for checking | |
$('.submit-button').on('click', function(event) { | |
alert('This is a dummy submit button. It does nothing.'); | |
event.preventDefault(); | |
}); | |
............................................. | |
Html /View File | |
............................................. | |
<div class="photo-upload"> | |
{!! Form::open(array('route' => 'photo.store', 'method' => 'put', 'files' => true)) !!} | |
<fieldset> | |
<label>UPLOAD PICTURE:</label> | |
<br/> | |
<img class="preview" id="preview" alt=" " src="{!!asset(Auth::user()->profile->img_url)!!}"> | |
<br/> | |
<br/> | |
<input type="file" name="image" id="imgInp" onchange="loadFile(event);"> | |
</fieldset> | |
<fieldset> | |
{!! Form::submit('Update Avatar', array('class' => 'btn btn-primary')) !!} | |
</fieldset> | |
{!! Form::close() !!} | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment