title: Laravel: Serialization of 'Illuminate\Http\UploadedFile' is not allowed
body: <p>I'm trying to upload an image, store it on disk and add the path to a JSON file that is stored on the database. 
  every user got a JSON file with all his images like:</p>
  
  <pre><code>{"images": ["/vendors/57/horse-11.png", "/vendors/57/horse-11.png"]}
  </code></pre>
  
  <p>That JSON file is stored in the database in the 'images' column.</p>
  
  <p>I'm struggling with this issue for days.. I always get following exception:</p>
  
  <pre><code>Serialization of 'Illuminate\Http\UploadedFile' is not allowed
  </code></pre>
  
  <p>the error occurs in this part of the code from the processImage function:</p>
  
  <pre><code>$image = Image::make($request-&gt;file('image'))
                  -&gt;resize(750, null, function ($constraint) {
                      $constraint-&gt;aspectRatio();
                  })
                  -&gt;encode('png');
  </code></pre>
  
  <p>I will guide you through the proces:</p>
  
  <p>first the user uploads an image, code:</p>
  
  <p><a href="https://codeshare.io/jGzQ9" rel="nofollow noreferrer">https://codeshare.io/jGzQ9</a></p>
  
  <p>secondly, via the routes.php a controller is called:</p>
  
  <pre><code>public function update(User $user, UserHouse $house, UserHouseRequest $request){
      $path = $this-&gt;processImage($request, $user-&gt;id, $house-&gt;id);
      $jsonstring = $house-&gt;images;
      array_push($jsonstring['images'], $path);
  
      $house-&gt;images = $jsonstring;
      $house-&gt;save();
  
      return back();
  }
  
  private function processImage($request, $userId, $houseId)
  {
      $path = null;
      $number = rand(1, 99);
      if ($request-&gt;hasFile('image')) {
          $image = Image::make($request-&gt;file('image'))
              -&gt;resize(750, null, function ($constraint) {
                  $constraint-&gt;aspectRatio();
              })
              -&gt;encode('png');
          $path = "/users/{$userId}/house-{$houseId}-{$number}.png";
          Storage::disk('fileadmin')-&gt;put($path, $image-&gt;encoded);
      }
  
      return $path;
  }
  </code></pre>
  
  <p>There is also some JS code, but I think that that isn't necessary for this problem. If it does, I will add it later.</p>
  
  <p>I'm using Laravel 5.5</p>
  
  <p>stacktrace:</p>
  
  <pre><code>2019-05-28 13:30:49] local.ERROR: Serialization of 'Illuminate\Http\UploadedFile' is not allowed {"userId":57,"email":"info@ho.com","exception":"[object] (Exception(code: 0): Serialization of 'Illuminate\\Http\\UploadedFile' is not allowed at /Users/sg/ah-website/user/laravel/framework/src/Illuminate/Session/Store.php:128)
  [stacktrace]
  #0 /Users/sg/website/user/laravel/framework/src/Illuminate/Session/Store.php(128): serialize(Array)
  #1 /Users/sg/website/user/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(87): Illuminate\\Session\\Store-&gt;save()
  #2 /Users/sg/website/user/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(218): Illuminate\\Session\\Middleware\\StartSession-&gt;terminate(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))
  #3 /Users/sg/website/user/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(189): Illuminate\\Foundation\\Http\\Kernel-&gt;terminateMiddleware(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))
  #4 /Users/sg/website/public/index.php(60): Illuminate\\Foundation\\Http\\Kernel-&gt;terminate(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))
  #5 /Users/sg/website/server.php(21): require_once('/Users/sg...')
  #6 {main}
  "} 
  </code></pre>
  
  <p>config/filesystems.php</p>
  
  <pre><code>&lt;?php
  
  return [
  
      /*
      |--------------------------------------------------------------------------
      | Default Filesystem Disk
      |--------------------------------------------------------------------------
      |
      | Here you may specify the default filesystem disk that should be used
      | by the framework. The "local" disk, as well as a variety of cloud
      | based disks are available to your application. Just store away!
      |
      */
  
      'default' =&gt; env('FILESYSTEM_DRIVER', 'local'),
  
      /*
      |--------------------------------------------------------------------------
      | Default Cloud Filesystem Disk
      |--------------------------------------------------------------------------
      |
      | Many applications store files both locally and in the cloud. For this
      | reason, you may specify a default "cloud" driver here. This driver
      | will be bound as the Cloud disk implementation in the container.
      |
      */
  
      'cloud' =&gt; env('FILESYSTEM_CLOUD', 's3'),
  
      /*
      |--------------------------------------------------------------------------
      | Filesystem Disks
      |--------------------------------------------------------------------------
      |
      | Here you may configure as many filesystem "disks" as you wish, and you
      | may even configure multiple disks of the same driver. Defaults have
      | been setup for each driver as an example of the required options.
      |
      | Supported Drivers: "local", "ftp", "s3", "rackspace"
      |
      */
  
      'disks' =&gt; [
  
          'local' =&gt; [
              'driver' =&gt; 'local',
              'root' =&gt; storage_path('app'),
          ],
  
          'public' =&gt; [
              'driver' =&gt; 'local',
              'root' =&gt; storage_path('app/public'),
              'url' =&gt; env('APP_URL').'/storage',
              'visibility' =&gt; 'public',
          ],
  
          's3' =&gt; [
              'driver' =&gt; 's3',
              'key' =&gt; env('AWS_KEY'),
              'secret' =&gt; env('AWS_SECRET'),
              'region' =&gt; env('AWS_REGION'),
              'bucket' =&gt; env('AWS_BUCKET'),
          ],
  
          'fileadmin' =&gt; [
              'driver' =&gt; 'local',
              'root' =&gt; public_path(),
              'visibility' =&gt; 'public',
              'url' =&gt; config('app.url'),
          ],
      ],
  
  ];
  </code></pre>