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');