我正在尝试在表单数据中上传图片
这是表单标题
{{ Form::open(array('url'=>'doAddProject', 'file'=>'true', 'method'=>'PUT')) }}
这是控制器
public function store()
{
$project = new Projects();
$file = Input::file('pImage');
$destination_path = 'images/projects/';
$filename = str_random(6) . '_' . $file->getClientOriginalName();
$file->move($destination_path, $filename);
$project->main_image = Input::file($filename);
$project->pro_title = Input::get('pName');
$project->pro_map = Input::get('pMap');
$project->pro_description = Input::get('pDetails');
$project->pro_serves = implode(",", array_filter(Input::get('pro_serves')));
$project->pro_activity = Input::get('activity');
$project->save();
return Redirect::to('admin/view-project')->with('message', 'Project add successfully');
}
收到错误:
在非对象
上调用成员函数getClientOriginalName()
答案 0 :(得分:2)
The Line
$project->main_image = Input::file($filename);
将其更改为
$project->main_image = $filename;