/*** @description: 保存base64位图片* @param {*} $base64Img 64位图片* @param {*} $name 文件名称* @return {*}*/public function saveBaseImg($base64Img,$name = ''){# base64数据$base64Img = str_replace(' ', '+', $base64Img);$baseString= explode(',', $base64Img);$data=base64_decode($baseString[1]);# 保存文件名$fileName = md5(time().rand(1,999)).$name;# 保存路径$imgPath="upload/".$fileName;# 写入图片内容file_put_contents($imgPath, $data);return $imgPath;}
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号