小编Spa*_*oyz的帖子

在非对象上调用成员函数getClientOriginalName()

我正在尝试制作图片上传器,但它总是给我这个错误

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)

我的代码出了什么问题?

php upload object laravel laravel-4

9
推荐指数
1
解决办法
4万
查看次数

JavaScript获取url段和参数

我已经阅读了一些问题,但我仍然无法弄清楚如何做到这一点
我有一个网址example.com/event/14aD9Uxp?p=10

在这里,我想获得14aD9Uxpp和
我尝试使用的值,split('/'+'?p=')但它不起作用
我想使用正则表达式,但我真的不明白如何使用它

javascript url

4
推荐指数
1
解决办法
8196
查看次数

标签 统计

javascript ×1

laravel ×1

laravel-4 ×1

object ×1

php ×1

upload ×1

url ×1