//base64图片上传 public function uploadCompressImg(Request $request) { $base64 = preg_replace("/\s/",'+',$request->input('img')); $img = base64_decode($base64); $disk = \Storage::disk('qiniu'); //使用七牛云上传 $img_name = date('Y/m/d-H:i:s-') . uniqid() . '.png'; $filename = $disk->put($img_name,$img);//上传 if(!$filename) { return $this->apiResponse(500, '上传失败'); } $img_url = $disk->getDriver()->downloadUrl($img_name); //获取下载链接 return $this->apiResponse(200, '上传成功',$img_url); }
laravel结合七牛实现base64的图片上传
最新推荐文章于 2023-05-09 16:42:59 发布