Create image from base64 string laravel

2019-12-07 19:26:51 Ashish Laravel

Simple function to Upload a Base 64 image in Laravel

public function createImageFromBase64(Request $request){
      
      $file_data       = $request->input('company_logo');
      //generating unique file name;
      $file_name = 'image_'.time().'.png';
      @list($type, $file_data) = explode(';', $file_data);
        @list(, $file_data)      = explode(',', $file_data);
      if($file_data!=""){
     		// storing image in storage/app/public Folder
                \Storage::disk('public')->put($file_name,base64_decode($file_data));
      
      }

}


This post is submitted by one of our members. You may submit a new post here.

Related Tricks