christopher's avatar

Save Image

I`m trying to save an image besides the user datas to the upload folder and store the filename to the database. Currently the image save is working but the image name is not passed to the database. What do i wrong ?

    $user = User::findOrFail($id);
    $user->fill(Input::except(array('thumbnail')));

    $image = Input::file('thumbnail');
    $path = 'uploads/'.$user->id.'';
    $filename = $image->getClientOriginalName();
    $upload = $image->move($path, $filename);

    $user->save();
0 likes
4 replies
mstnorris's avatar

You've got $user->fill(Input::except(array('thumbnail')));, is that not it?

christopher's avatar

If i do

 $user->fill(Input::all());

the path is also not saved to the database. I thought i have to except the thumbnail because i need to first grab the image name, file and move it into a directory and then save it.

christopher's avatar
christopher
OP
Best Answer
Level 30

ok solved it.

instead of using $upload you have to use $news->thumbnail

Please or to participate in this conversation.