dimanche 9 juin 2019

Cannot use object of type Illuminate\Http\UploadedFile as array. Finding this error while updating file

i am finding this error while updating file. This is my following code for updating file.

public function update(Request $request, $id)
    {
        //
        $request->validate([
            'name' => 'required', 
                'note'=>'required',
        ]);

        $category = Category::find($id);
        $category->name =  $request->get('name');
        $icon = $request->file('icon');
        if(isset($icon) && !empty($icon))
        {
        $new_name = '/icon/'.'_'.date('d-m-Y-H-i-s') . '.' . $icon->getClientOriginalName();

        $icon->move(public_path('/images/category'), $new_name);
        $icon['icon']=$new_name;
        $category->icon=$icon;
    }
        // $category->icon=$icon;
        $category->note = $request->get('note');
        $category->updated_by = Auth::user()->id;

        $category->save();

    }

Please help me out to solve to find the solution.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire