Function to create an image from base64 format in Laravel 5.4

Uploading a Base 64 image in laravel 5.4
Uploading a Base 64 image in laravel 5.4

Uploading a Base 64 image in laravel 5.4


//Function to save a base64 image in laravel 5.4
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));
      
      }

}

Leave a Reply

Your email address will not be published. Required fields are marked *