Monday, March 6, 2017

Laravel saving image to public folder?

So I am trying to save uploaded image to laravel/public folder and return src so a path to where the file has been saved, however nothing happens after I choose an image and I get no errors, what might be wrong?

public function testing(Request $request) {
    if(Input::file())
    {
        $image = Input::file('img');
        $filename = time() . '.' . $image->getClientOriginalExtension();
        $path = public_path('images/' . $filename);
        Image::make($image->getRealPath())->resize(200, 200)->save($path);
        $user->image = $filename;
        $user->save();
    }
}


<form action="" enctype="multipart/form-data" role="form" method="POST">
    <input id="img" class="form-control filestyle margin images" data-input="false" type="file" data-buttonText="Upload Logo" data-size="sm" data-badge="false" onchange="uploadImage();" />
</form>



via Przemek

Advertisement