First u need to write a function in jquery
$('.filestyle').on('change',function(e){
var file = e.target.files[0],reader = new FileReader();
reader.onload =function(c){
$('#image').attr('src',c.target.result);
}
});
Basically I want to upload an image and display it to an user, at the moment when image is selected, nothing happens I get no error mistakes or anything else and I am wondering what is going on. So basically I want to upload an image and display it inside img by replacing src="#" with link to a file which has been saved to public folder.
Here is my code:
<form action="{{ action('BuilderController@testing') }}" role="form" method="POST">
<input class="form-control filestyle margin images" data-input="false" type="file" data-buttonText="Upload Logo" data-size="sm" data-badge="false" />
</form>
<div class="logo">
<img class="images" id="image" src="#" alt="Your Logo"/>
</div>
Controller:
public function testing() {
if(Input::file())
{
$image = Input::file('photo');
$filename = time() . '.' . $image->getClientOriginalExtension();
$path = public_path('images/' . $filename);
Image::make($image->getRealPath())->resize(200, 200)->save($path);
$user->image = $filename;
$user->save();
}
}
Please or to participate in this conversation.