Laravel Call to a member function getClientOriginalExtension() on null
<p>Hello im getting the following error while upload an image using laravel: "Call to a member function getClientOriginalExtension() on null".</p>

<p>Here is my controller:</p>

<pre><code>$imageName = rand(11111, 99999) . '.' . $request-&gt;file('image')-&gt;getClientOriginalExtension();
            $destinationPath = 'events';
            $fileName = rand(11111, 99999) . '.' . $extension;
            $upload_success = $image-&gt;move($destinationPath, $imageName);
</code></pre>

<p>Here is my view:</p>

<pre><code>{!! Form::file('image', null, ['class' =&gt; 'form-control']) !!}
</code></pre>

<p>How do i save the $imageName to the pic field in my database. I tried this but it doesn't work. The field remains empty in the table.</p>

<pre><code>$task=$request-&gt;user()-&gt;tasks()-&gt;create([
            'name' =&gt; $request-&gt;name,
            'description' =&gt; $request-&gt;description,
            'location' =&gt; $request-&gt;location,
            'pic' =&gt; $imageName,
        ]);
</code></pre>