我正在尝试制作图片上传器,但它总是给我这个错误
Call to a member function getClientOriginalName() on a non-object
Run Code Online (Sandbox Code Playgroud)
这是我的代码控制器代码
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');
}
}
Run Code Online (Sandbox Code Playgroud)
这是上传表格
<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>
Run Code Online (Sandbox Code Playgroud)
我的代码出了什么问题?
我已经阅读了一些问题,但我仍然无法弄清楚如何做到这一点
我有一个网址example.com/event/14aD9Uxp?p=10
在这里,我想获得14aD9Uxp
p和
我尝试使用的值,split('/'+'?p=')
但它不起作用
我想使用正则表达式,但我真的不明白如何使用它