Level 41
To access the file, you need to use the file method, not the get method.
$request->file('avatar')
Also, make sure that your form has enctype="multipart/form-data".
Hey, i been try to upload a file but its not uploading and also its not saving to the data
Here is my code
public function update(profileRequest $request, $username)
{
$user = User::whereUsername($username)->firstOrFail();
$user->profile->title = $request->get('title');
$user->profile->bio = $request->get('bio');
$user->profile->location = $request->get('location');
$user->profile->phone_number = $request->get('phone_number');
$user->profile->twitter = $request->get('twitter');
$user->profile->github = $request->get('github');
$user->profile->facebook = $request->get('facebook');
$user->profile->google = $request->get('google');
$user->profile->linkedin = $request->get('linkedin');
$user->profile->avatar = $this->updateAvatar($request->get('avatar'));
$user->profile->save();
Flash::success('Successfully updated your profile');
return Redirect::back();
}
public function updateAvatar($image){
$fileName = date('y-m-d-H:i:s')."-".$image->getClientOrginalName();
$path = public_path('/assets/uploads/users/'.$fileName);
Image::make($image->getRealPath())->resize(263, 263)->save($path);
}
if i update all data with out Avatar line, its work but with with the Avatar its not working. please help.
To access the file, you need to use the file method, not the get method.
$request->file('avatar')
Also, make sure that your form has enctype="multipart/form-data".
Please or to participate in this conversation.