Laravel 6 , PHP , Laravel , Laravel 7
In this example,I will learn you how to easy convert base64 image upload in laravel.you can easy and simply convert to base64 image upload in laravel.i will write simple code for save base64 encoded image to file using php and you can save it png, jpg as you want.
While working with API for app, You will notice that they will send the format of images in Base64 encoded. So in that case, you will need to move the Base64 encoded images to server as a image file.
Here in this example i write function createImage() from base64 string. you can simply follow bellow example:
public function createImage($img)
$folderPath = "images/";
$image_parts = explode(";base64,", $img);
$image_type_aux = explode("image/", $image_parts);
$image_type = $image_type_aux;
$image_base64 = base64_decode($image_parts);
$file = $folderPath . uniqid() . '. '.$image_type;
It will help you....