diff --git a/app/api/controller/File.php b/app/api/controller/File.php index d832a245..e9782ebe 100755 --- a/app/api/controller/File.php +++ b/app/api/controller/File.php @@ -61,13 +61,25 @@ class File extends Api public function aliOSS() { try{ - dump($this->request->post()); - die; -// $result = UploadAliOSS::uploadImage(); -// if ($result['code'] == 1) { -// return JsonServer::success('上传成功', $result['data']); -// } -// return JsonServer::error('上传失败'); + $post = $this->request->post(); + if (is_array(self::$APP_UPLOAD_PATH[$post['type']])) { + $path = self::$APP_UPLOAD_PATH[$post['type']]; + + // 本地生活商家上传商品 + if ($post['type'] === 'local_shop_add' && $post['lstore_id'] > 0) { + $path .= '/' . $post['lstore_id']; + } else { + return JsonServer::error('缺少参数'); + } + + $result = UploadAliOSS::uploadImage($path); + if ($result['code'] == 1) { + return JsonServer::success('上传成功', $result['data']); + } + return JsonServer::error('上传失败'); + } else { + return JsonServer::error('上传文件类型不存在'); + } }catch(\Exception $e) { return JsonServer::error($e->getMessage()); }