title: NotWritableException: Can't write image data to path
body: <p>I wrote this to upload an image to s3 and I only get this error on my test server, on <code>localhost</code> profile picture upload successfully without getting an error. <code>php.ini</code> files are same on both <code>localhost</code> and <code>testing</code> environments. Also AWS Credentials given right.</p>
  <p>On test server code execute into <code>if (!File::exists($folderPath)) {</code> To my knowledge I wrote that part. Here's the code.</p>
  <pre><code>                if ((strpos($profilePic, 'data:image/png;base64,') !== false)
                      || (strpos($profilePic, 'data:image/jpeg;base64,') !== false)) {
  
                      $img = Image::make($profilePic)-&gt;orientate();
                  } else {
                      
                      $img = Image::make(base64_decode($profilePic))-&gt;orientate();
                  }
  
                  $original = 'avater.png';
                  $small = 'avater_small.png';
                  $medium = 'avater_medium.png';
  
                  $folderPath = 'uploads/profile_pictures/'.$userId;
  
                  $fullPath = $folderPath.'/'.$original;
                  $fullPathSmall = $folderPath.'/'.$small;
                  $fullPathMedium = $folderPath.'/'.$medium;
                  
                  if (!File::exists($folderPath)) {
                      File::makeDirectory($folderPath, 0775, true);
                  }
  
                  $smallImg = clone $img;
                  $mediumImg = clone $img;
  
                  if ($img-&gt;height() &gt; $img-&gt;width()) {
                      // resize the image to a width of 300 and constrain aspect ratio          
                      $smallImg-&gt;resize(400, null, function ($constraint) {
                          $constraint-&gt;aspectRatio();
                      });
  
                      $mediumImg-&gt;resize(800, null, function ($constraint) {
                          $constraint-&gt;aspectRatio();
                      });
                  } else {
                      // resize the image to a height of 200 and constrain aspect ratio
                      $smallImg-&gt;resize(null, 400, function ($constraint) {
                          $constraint-&gt;aspectRatio();
                      });
  
                      $mediumImg-&gt;resize(null, 400, function ($constraint) {
                          $constraint-&gt;aspectRatio();
                      });
                  }
  
                  $img-&gt;save($fullPath);
                  $smallImg-&gt;save($fullPathSmall);
                  $mediumImg-&gt;save($fullPathMedium);
                  Storage::disk('s3')-&gt;put($fullPath, file_get_contents($profilePic), 'public');
                  Storage::disk('s3')-&gt;put($fullPathMedium, file_get_contents($profilePic), 'public');
                  Storage::disk('s3')-&gt;put($fullPathSmall, file_get_contents($profilePic), 'public');
  
                  $user_repository = \App::make('App\Repositories\Contracts\UserRepositoryInterface');
  
                  // $data = ['profile_image' =&gt; asset('uploads/profile_pictures/'.$userId.'/'.$original)];
                  $data = ['profile_image' =&gt; '/uploads/profile_pictures/'.$userId.'/'.$original];
  
                  $item_image = $user_repository-&gt;updateUser($userId,$data);
  
                  return true;
  </code></pre>