任何人都可以帮助我吗?我尝试为我的项目更新新图像,但出现错误。如果我不选择新图像,只需更新内容就可以了,但使用新图像我无法更新。这是我的代码
public function updateStudent(UpdateStudentRequest $request){//(Request $request)
$id = $request->input('id');
$student = Students::find($id);
if( $request->hasFile('pic') ){
$path = 'images/';
$file = Image::make(input::file('pic'));
$fileName = Input::file('pic')->getClientOriginalName();
$file->save($path."original/".$fileName);
$students->original = $path."original/".$fileName;
//get the desire image size
$file->fit(120,90);
$file->save($path."fit/".$fileName);
$students->image = $path."fit/".$fileName;
}
$student->first_name = $request->input('first_name');
$student->last_name = $request->input('last_name');
$student->email = $request->input('email');
$student->password = $request->input('password');
$student->address = $request->input('address');
$student->save();
}
这是错误:
ErrorException in Crud.php line 73:
Creating default object from empty value