title: Laravel Call to a member function on a non-object
body: <p>I have searched on stack and found many questions like this...</p>
  
  <p>However, I am sure that I am using an object and have verified that in the dump.</p>
  
  <p><strong>Error</strong></p>
  
  <p><code>&gt;16: Call to a member function getRealPath() on a non-object</code></p>
  
  <p><strong>Line 16</strong></p>
  
  <p><code>$image-&gt;getRealPath();</code></p>
  
  <p><strong>Var Dump $image</strong></p>
  
  <pre><code>object(Symfony\Component\HttpFoundation\File\UploadedFile)#9 (7) { ["test":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=&gt; bool(false) ["originalName":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=&gt; string(41) "5a862f92da957da3e0208357ce006afd_970x.jpg" ["mimeType":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=&gt; string(10) "image/jpeg" ["size":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=&gt; int(346047) ["error":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=&gt; int(0) ["pathName":"SplFileInfo":private]=&gt; string(24) "C:\xampp\tmp\phpA5C7.tmp" ["fileName":"SplFileInfo":private]=&gt; string(11) "phpA5C7.tmp" } 
  </code></pre>
  
  <p>If I dump <code>$image-&gt;getRealPath();</code> I get a <code>string(24) "C:\xampp\tmp\phpE193.tmp"</code> which is what I want.  I have no idea why it's saying $image is not an object when clearly it is.</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code># Process Images - Queue?
  if ($filesUploaded) {
      $images = Input::file('images');
      foreach ($images as $image) {
          # Record Creation
          $record = new Image;
          $record-&gt;user_id = Auth::id();
          $record-&gt;ad_id = $adId;
          $record-&gt;name = Str::random();
          $record-&gt;save();
          # Create TN
          $record-&gt;createTN($image);
          # Create Smalls
          # Create Larges
      }
  }
  </code></pre>
  
  <p><strong>Image class</strong></p>
  
  <pre><code>public function createTN($image) {
      $PUBLIC_PATH = public_path();
  
  # Load Zebra Image Library
  require_once $PUBLIC_PATH.'/uploads/Zebra_Image.php';
  
  $destinationPath = $PUBLIC_PATH.'/uploads/thumbnails/';
  $tn = new Zebra_Image();
  $tn-&gt;source_path = $image-&gt;getRealPath();
  $tn-&gt;target_path = $destinationPath.$this-&gt;name.'_sm.jpg';
  $tn-&gt;jpeg_quality = 60;
  $tn-&gt;preserve_aspect_ratio = true;
  $tn-&gt;enlarge_smaller_images = true;
  $tn-&gt;resize(100, 100, ZEBRA_IMAGE_CROP_CENTER);
  }
  </code></pre>