Saturday, March 4, 2017

Laravel 5 Uploading and display image

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.

Here is my code:

<form action="" 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();
    }
}



via Przemek

Advertisement