Upload Image with laravel 5.1
how can i upload image in laravel 5.1 ?
i try to read doc but it can't help me
please help mee
you will need to do something like this in the controller that handles the input
public function handleImageUpload(\Request $request){
// $file = $request->file('image'); or
// $fileName = 'somename';
$request->file('image')->move($destinationPath, $fileName);
}
more methods can be found here as well
public function update_avatar(Request $request)
{
if($request->hasFile('avatar')){
$avatar = $request->file('avatar');
$filename = time() . '.' . $avatar->getClientOriginalExtension();
Image::make($avatar)->resize(300, 300)->save( public_path('uploads/avatars/' . $filename));
$user = Auth::user();
$user->avatar = $filename;
$user->save();
}
return view('home');
}
Please or to participate in this conversation.