Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save talha08/2762111e928a6751d57c38eebb96c635 to your computer and use it in GitHub Desktop.
Save talha08/2762111e928a6751d57c38eebb96c635 to your computer and use it in GitHub Desktop.
............................................
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