path $ = root_path 'public / uploads / headimg'. ; $ PIC = base64_image_content ( $ base64_image , $ path ); // Image Path $ type = str_replace '.' (, '', The strrchr ( $ PIC , ''). ); // Get picture type $ image = str_replace ( 'Data: image / PNG; Base64,', '', $ base64_image ); // Base64 conversion $ image = str_replace ( '', '+', $ image ) ; $image = base64_decode($image); img_url $ = Oss :: ossUploadFile64 ( $ Image , $ of the type , $ PIC , 'pSignatureImg'); // uploaded to the oss // save the image to a local path bases64 $ base64_image_content Base64 picture $ path to save the image public function base64_image_content ( $ base64_image_content , $ path ) { // match the format of the picture IF ( the preg_match ( '/ ^ (Data: \ S * image \ / (\ W +); Base64,) /', $ base64_image_content , $ Result )) { $ type = Result $ [2 ]; $ new_file= $ Path "/." ; IF (! File_exists ( $ new_file )) { // check for the folder, if not created, and given the highest authority mkdir ( $ new_file , 0777, to true ); } $ new_file = new_file $ . microtime, and ( to true .) RAND (0,999). "{. $ type }" ; IF ( file_put_contents ( $ new_file , base64_decode ( str_replace ( $ Result [. 1], '',$base64_image_content)))){ return $new_file; }else{ return false; } }else{ return false; } }