title: Laravel: Save Base64 .png file to public folder from controller
body: <p>I send a png image file to controller in base64 via Ajax. I've already test and sure that controller has received id but still can't save it to public folder.</p>
  
  <p><strong>Here is my controller</strong></p>
  
  <pre><code>public function postTest() {
          $data = Input::all();
  
          //get the base-64 from data
          $base64_str = substr($data-&gt;base64_image, strpos($data-&gt;base64_image, ",")+1);
  
          //decode base64 string
          $image = base64_decode($base64_str);
          $png_url = "product-".time().".png";
          $path = public_path('img/designs/' . $png_url);
  
          Image::make($image-&gt;getRealPath())-&gt;save($path);
          // I've tried using 
          // $result = file_put_contents($path, $image); 
          // too but still not working
  
          $response = array(
              'status' =&gt; 'success',
          );
          return Response::json( $response  );
  }
  </code></pre>