Friday 18 August 2017

Laravel 5.3 Upload Image With user Information

Here is the working code for Laravel 5.3 Upload Image With user Information, Today I have done this code after facing image upload problem with save Image name in database and I have solved it and I am sharing with you all.


public function store(Request $request)
{
$this->validate($request, [
'price' => 'numeric',
'width' => 'numeric',
'height' => 'numeric',
'depth' => 'numeric',
'parts_warranty' => 'numeric',
'labor_warranty' => 'numeric',
'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:250|dimensions:max_width=250,max_height=250',
]);
/*Image Upload*/
$imageName = time().'.'.$request->image->getClientOriginalExtension();
$imageNamepath = $request->image->move(public_path('images'), $imageName);
/*Image Upload*/
$input = $request->all();
$input['image'] = $imageName;
$coil = Coils::create($input);
Session::flash('success', 'New coil added successfully.');
return redirect('/unit-list');
}

No comments:

Post a Comment

Google Map Filter Api Example

Here is Google Map Filter Api Example: