title: Save value Base64 to Image PNG use Intervention image Laravel Storage
body: <p>How can I convert Base64 value to Image PNG using intervention image and laravel storage?</p>
  <pre class="lang-php prettyprint-override"><code>public function userLogout(Request $request) {
    $data = $request-&gt;all();
    if ($request-&gt;isMethod('post')) {
      $poster = explode(&quot;;base64&quot;, $request-&gt;picture);
      $image_type = explode(&quot;image/&quot;, $poster[0]);
      $mime_type = '.'.$image_type[1];
      $image_base = base64_decode($poster[1]);
  
      $data['picture'] = Storage::disk('player-images')-&gt;put($image_base, file_get_contents($poster));
  
      $path = public_path('storage/player-images/'.$image_base);
  
      Image::make($poster)-&gt;save($path);
  
      $data['picture'] = 'player-images/' . $image_base;
      User::where('name', Auth::user()-&gt;name)-&gt;update($data);
  
    }
    return view('gallery');
  }
  </code></pre>
  <p>i got an error message:</p>
  <blockquote>
  <p>&quot;file_get_contents() expects parameter 1 to be a valid path, array given&quot;</p>
  </blockquote>
  <p>and here is my ajax function</p>
  <pre class="lang-js prettyprint-override"><code>var canvas = document.getElementById('canvas');
  var dataUrl = canvas.toDataURL('image/png');
  $(document).ready(function(){
      $('#save').click(function(e){
          e.preventDefault();
  
          $.ajax({
            headers: {'X-CSRF-TOKEN': $('meta[name=&quot;csrf_token&quot;]').attr('content')},
            type: &quot;POST&quot;,
            url: &quot;/gallery&quot;,
            data: {
              picture: dataUrl,
            }
          }).done(function(o) {
              console.log(&quot;saved&quot;);
          });
      });
  });
  </code></pre>
  <p>How can i save the base64 value to database like player-images/blabla.png and store image to path public/storage/player-images/</p>
  <p>sorry, my English is bad.
  thanks.</p>