【发布时间】:2013-12-01 04:30:07
【问题描述】:
我正在尝试制作一个图片上传器,但它总是给我这个错误
Call to a member function getClientOriginalName() on a non-object
这是我的代码控制器代码
public function uploadImageProcess(){
$destinatonPath = '';
$filename = '';
$file = Input::file('image');
$destinationPath = public_path().'/assets/images/';
$filename = str_random(6).'_'.$file->getClientOriginalName();
$uploadSuccess = $file->move($destinationPath, $filename);
if(Input::hasFile('image')){
$images = new Images;
$images->title = Input::get('title');
$images->path = '/assets/images/' . $filename;
$image->user_id = Auth::user()->id;
Session::flash('success_insert','<strong>Upload success</strong>');
return Redirect::to('user/dashboard');
}
}
这是上传表格
<form role="form" action="{{URL::to('user/poster/upload_process')}}" method="post">
<label>Judul Poster</label>
<input class="form-control" type="text" name="title">
<label>Poster</label>
<input class="" type="file" name="image"><br/>
<input class="btn btn-primary" type="submit" >
</form>
我的代码有什么问题?
【问题讨论】:
标签: php object upload laravel laravel-4