title: save image stream to laravel
body: <p>In my Laravel controller I'm attempting to take a string of png image data, then save it as a <code>png</code> to storage using <code>put</code>:</p>
  
  <pre><code>$image_string = $request-&gt;get('image_string', false);
  $filename = 'temp_image';
  
  if ($image_string) {
      $resource = imagecreatefromstring($image_string);
      Log::debug("Storing image");
      if ($resource !== false) {
          Storage::put('public/' . $filename . '.png', imagepng($resource));
      } else {
          Log::error("Failed to get resource from string");
      }
  }
  </code></pre>
  
  <p>If I break out just the <code>imagecreatefromstring($image_string)</code> and <code>imagepng($resource)</code> parts, the file is created as expected. But somewhere in the <code>Storage::put</code> the image is either corrupted or lost, because while an image with the right filename and extension exists, it has no data and appears as a black box when viewed.</p>
  
  <p>Is there a different way I need to handle the image store routine?</p>