laravel 5.2 | upload file - Call to a member function getClientOriginalName() on null
<p>i tried to upload profile picture pict but i got error "Call to a member function getClientOriginalName() on null"</p>

<p>this is my method : </p>

<pre><code>  $data = $request-&gt;input('fotodosen');
    $photo = $request-&gt;file('fotodosen')-&gt;getClientOriginalName();
    $destination = base_path() . '/public/uploads';
    $request-&gt;file('fotodosen')-&gt;move($destination, $photo);
    $data['fotodosen'] = $photo;
    Dosen::create($data);
</code></pre>

<p>create : </p>

<pre><code> {!! Form::open(array('fotodosen'=&gt;'create', 'method'=&gt;'POST', 'files'=&gt;true, 'url'=&gt;'uploads')) !!}
             {!! Form::file('image') !!}
                   &lt;div class="form-group"&gt;
                        &lt;div class="col-md-6 col-md-offset-4"&gt;
                            &lt;button type="submit" class="btn btn-primary"&gt;
                                &lt;i class="fa fa-btn fa-user"&gt;&lt;/i&gt; Register
                            &lt;/button&gt;
                             {!! Form::close() !!}
</code></pre>

<p>already edit method to : </p>

<pre><code> $photo = $request-&gt;file('fotodosen')-&gt;getClientOriginalName($photo);
</code></pre>

<p>still got that error. what am i missing?</p>

<p><strong>UPDATE :</strong> </p>

<pre><code>public function store(CreateDosenRequest $request)

{



    $user = User::create([
        'name' =&gt; $request-&gt;input('name'),
        'username' =&gt; $request-&gt;input('username'),
        'email' =&gt; $request-&gt;input('email'),
        'password' =&gt; $request-&gt;input('password'),
        'admin' =&gt; $request-&gt;input('admin'),
     ]);

      $dosen = Dosen::create([
        'iddosen' =&gt; $request-&gt;input('iddosen'),
        'nipy' =&gt; $request-&gt;input('nipy'),
        'namadosen' =&gt; $user-&gt;name,
        'user_id' =&gt; $user-&gt;id,
        'alamatdosen' =&gt; $request-&gt;input('alamatdosen'),
        'notelpdosen' =&gt; $request-&gt;input('notelpdosen'),
        'tempatlahirdosen' =&gt; $request-&gt;input('tempatlahirdosen'),
        'tanggallahirdosen' =&gt; $request-&gt;input('tanggallahirdosen'),
        'agamadosen' =&gt; $request-&gt;input('agamadosen'),

    ]);
        if ($request-&gt;hasFile('image')) {
            $data = $request-&gt;input('image');
            $photo = $request-&gt;file('image')-&gt;getClientOriginalName();
            $destination = public_path() . '/uploads/';
            $request-&gt;file('image')-&gt;move($destination, $photo);
            $data['fotodosen'] = $photo;
            Dosen::create($data);
 }
</code></pre>