From 75c7cd4d6bb4d8a40e3179170154488e7f66a472 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Thu, 19 Oct 2023 17:36:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0ocr=E8=AF=86=E5=88=AB?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/XunFeiController.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/api/controller/XunFeiController.php b/app/api/controller/XunFeiController.php index 1bbc82654..01d0a19bf 100644 --- a/app/api/controller/XunFeiController.php +++ b/app/api/controller/XunFeiController.php @@ -377,10 +377,11 @@ class XunFeiController extends BaseApiController public function ocr() { $ocrHostUrl = "https://api.xf-yun.com/v1/private/sf8e6aca1"; - $file = request()->file('image'); + $file = request()->param('image'); if (empty($file)) { return $this->fail('未上传图片文件'); } + /* // 上传图片临时文件 $savename = \think\facade\Filesystem::putFile('ocr', $file); $file = app()->getRootPath() . '/runtime/storage/' . $savename; @@ -392,11 +393,8 @@ class XunFeiController extends BaseApiController return $this->fail('图片文件不能超过4M'); } $ext = pathinfo($file, PATHINFO_EXTENSION); + */ $base64_image = base64_encode(file_get_contents($file)); - if (file_exists($file)) { - // 删除临时文件 - unlink($file); - } $ocr = new OcrClient($this->app_id, $this->api_key, $this->api_secret); $ocrHostUrl = $ocr->assembleAuthUrl($ocrHostUrl); $requestBody = [