hEShaN hEShaN - 4 months ago 82
PHP Question

Laravel 5.3 image upload issue

I am new to laravel 5.3. I need to upload the image to the database table spare. Here is my controller. The error i am getting is also attached.Please help thanks in advance.

public function store(Request $request)
$Spare=new Spares;
$file = $request->file('image');

// Get the contents of the file
$contents = $file->openFile()->fread($file->getSize());


\Session::flash('flash_message','Added new Spare.'); //<--FLASH MESSAGE

return redirect()->back();
catch (\Illuminate\Database\QueryException $ex){

I am getting this error.

enter image description here


Since you haven't provided the HTML for this form I'll take a guess that your <form> tag is missing enctype="multipart/form-data". This attribute is required for uploading files.