/**
* @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;
}
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!