title: Laravel: Call to a member function getRealPath() on a non-object
body: <p>I'm creating a website for a client with a gallery for images etc.</p>
  
  <p>I'm running into this error:</p>
  
  <p><code>ImageController Line 16: Call to a member function getRealPath() on a non-object</code></p>
  
  <p><code>ImageController</code> looks like this:</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers;
  
  use App\Http\Controllers\Controller;
  use App\Image;
  use Illuminate\Http\Request;
  
  class ImageController extends Controller {
  
      public function __construct() {
  
  }
  
  public function store(Request $request) {
      $file = $request-&gt;file('image')-&gt;getRealPath();
      $image = new Image();
      $image-&gt;title = $request-&gt;get('title');
      $image-&gt;desc = $request-&gt;get('desc');
      //$image-&gt;date = $request-&gt;get('created_at');
      $image-&gt;image = base64_encode(file_get_contents($file));
      $image-&gt;type = pathinfo($file, PATHINFO_EXTENSION);
      if($image-&gt;save()) {
          return redirect(route('web.home'))-&gt;with('status', 'Uploaded!');
      } else {
          return redirect(route('store.upload'))-&gt;with('status', 'Upload failed!')-&gt;withInput();
      }
  }
  
  }
  </code></pre>
  
  <p>and my form looks like this:</p>
  
  <pre><code>&lt;form action="{{ url(route('store.upload')) }}" method="post" enctype="multipart/form-data"&gt;
  {!! csrf_field() !!}
  &lt;div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"&gt;
      &lt;input class="mdl-textfield__input" type="text" id="title" name="title"&gt;
      &lt;label class="mdl-textfield__label" for="title"&gt;Titel&lt;/label&gt;
  &lt;/div&gt;
  &lt;div class="mdl-textfield mdl-js-textfield"&gt;
      &lt;textarea class="mdl-textfield__input" type="text" rows="5" id="desc"&gt;&lt;/textarea&gt;
      &lt;label class="mdl-textfield__label" for="desc"&gt;Beschrijving&lt;/label&gt;
  &lt;/div&gt;
  &lt;input type="file" name="image"&gt;
  &lt;button class="mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--colored right" type="submit"&gt;
      &lt;i class="material-icons"&gt;add&lt;/i&gt;
  &lt;/button&gt;
  </code></pre>
  
  <p></p>
  
  <p>This is basically an edit of an earlier gallery I created and should (in theory) work.</p>