oxbir
1 week ago
122
9
Laravel

Array to string conversion when upload an image

Posted 1 week ago by oxbir

Look at my codes.

public function store(Request $request)
{

    $logoFile = $request->logo;
    $imageFile = $request->image;
    if ($request->hasFile('logo')) {
        $logo = $request->file('logo');
        $logoFile = $logo->getClientOriginalName();
        $logo->move(public_path('images/logos'), $logoFile);
    }
    if ($request->hasFile('image')) {
        $image = $request->file('image');
        $imageFile = $image->getClientOriginalName();
        $image->move(public_path('images/images'), $imageFile);
    }
    Style::create([
        'lang' => $request->lang,
        'first_name' => $request->first_name,
        'last_name' => $request->last_name,
        'mobile' => $request->mobile,
        'birth_date' => $request->birth_date,
        'field_sport' => $request->field_sport,
        'coach_degree' => $request->coach_degree,
        'referee_degree' => $request->referee_degree,
        'don' => $request->don,
        'gender' => $request->gender,
        'marital_status' => $request->marital_status,
        'championship_titles' => $request->championship_titles,
        'national_code' => $request->national_code,
        'job' => $request->job,
        'style_name' => $request->style_name,
        'email' => $request->email,
        'founder' => $request->founder,
        'website' => $request->website,
        'image' => $imageFile,
        'logo' => $logoFile
    ]);
    return redirect()->back();
}

I get this error.

Array to string conversion

errors

Please sign in or create an account to participate in this conversation.