//Code to call function
$base64file = $request->input('filename');
$input['filename'] = rand().'.png';
$canvasimagepath = public_path('files/'.$input['filename']); //uploaded path with image name
base64_to_jpeg($base64file, $canvasimagepath); ///Calling function to upload image from base64_string
//Function to convert base64_string to image and upload
function base64_to_jpeg($base64_string, $output_file) {
$ifp = fopen($output_file, "wb");
$data = explode(',', $base64_string);
fwrite($ifp, base64_decode($data[1]));
fclose($ifp);
return $output_file;
}
$base64file = $request->input('filename');
$input['filename'] = rand().'.png';
$canvasimagepath = public_path('files/'.$input['filename']); //uploaded path with image name
base64_to_jpeg($base64file, $canvasimagepath); ///Calling function to upload image from base64_string
//Function to convert base64_string to image and upload
function base64_to_jpeg($base64_string, $output_file) {
$ifp = fopen($output_file, "wb");
$data = explode(',', $base64_string);
fwrite($ifp, base64_decode($data[1]));
fclose($ifp);
return $output_file;
}
Comments
Post a Comment