Blogger Information
Blog 51
fans 0
comment 1
visits 64957
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP 保存base64位图片
鱼的熊掌
Original
1067 people have browsed it
  1. /**
  2. * @description: 保存base64位图片
  3. * @param {*} $base64Img 64位图片
  4. * @param {*} $name 文件名称
  5. * @return {*}
  6. */
  7. public function saveBaseImg($base64Img,$name = '')
  8. {
  9. # base64数据
  10. $base64Img = str_replace(' ', '+', $base64Img);
  11. $baseString= explode(',', $base64Img);
  12. $data=base64_decode($baseString[1]);
  13. # 保存文件名
  14. $fileName = md5(time().rand(1,999)).$name;
  15. # 保存路径
  16. $imgPath="upload/".$fileName;
  17. # 写入图片内容
  18. file_put_contents($imgPath, $data);
  19. return $imgPath;
  20. }
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!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post