From d90fd9bcaab3eb1d09d8a233a3fa534ffed4d2c2 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Mon, 11 Sep 2023 17:46:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=8A=E4=BC=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/merchant/Common.php | 18 ++++++++++++++++++ route/api.php | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/controller/merchant/Common.php b/app/controller/merchant/Common.php index e0fe41dc..922c73c2 100644 --- a/app/controller/merchant/Common.php +++ b/app/controller/merchant/Common.php @@ -273,6 +273,24 @@ class Common extends BaseController return app('json')->success(['src' => tidy_url($upload->getFileInfo()->filePath)]); } + public function uploadFile() + { + $file = $this->request->file('file'); + if (!$file) + return app('json')->fail('请上传文件'); + validate(["file|文件" => [ + 'fileSize' => config('upload.filesize'), + 'fileExt' => 'apk,ipa,doc,pdf,txt', + 'fileMime' => '', + ]])->check(['file' => $file]); + $upload = UploadService::create(); + $data = $upload->to('media')->validate([])->move('file'); + if ($data === false) { + return app('json')->fail($upload->getError()); + } + return app('json')->success(['src' => tidy_url($upload->getFileInfo()->filePath)]); + } + public function config() { $data = systemConfig(['tx_map_key','delivery_status','delivery_type']); diff --git a/route/api.php b/route/api.php index 8e99978c..8fdcda2d 100644 --- a/route/api.php +++ b/route/api.php @@ -552,7 +552,7 @@ Route::group('api/', function () { })->prefix('api.article.'); Route::post('upload/video', 'merchant.Common/uploadVideo'); - Route::post('upload/file', 'merchant.Common/uploadVideo'); + Route::post('upload/file', 'merchant.Common/uploadFile'); Route::get('excel/download/:id', 'merchant.store.order.Order/download'); //申请商户 Route::post('intention/create', 'api.store.merchant.MerchantIntention/create');