Commit 7f923275 authored by zhuwei's avatar zhuwei

图片上传

parent 2ce7c152
<?php
namespace app\api\controller;
use app\api\extend\Basic;
use app\api_broker\service\UploadFileService;
use think\Request;
class UploadImg extends Basic{
private $uFService;
public function __construct(Request $request = null)
{
parent::__construct($request);
$this->uFService = new UploadFileService();
}
/**
* 图片上传
* @return \think\Response
*/
public function uploadImg()
{
header('Access-Control-Allow-Origin:*');
set_time_limit(0);
$file = $_FILES['image'];
$type = request()->param('type');
$uploadResult = $this->uFService->upload($file, $type);
if ($uploadResult["code"] == 200) {
return $this->response("200", "图片上传成功", $uploadResult["msg"]);
} else {
return $this->response("101", $uploadResult["msg"]);
}
}
}
\ No newline at end of file
......@@ -677,6 +677,7 @@ Route::group('api', [
'getFindShop' => ['api/FindShop/getFindShopByParams', ['method' => 'get|post']],
'getRecommendShopList' => ['api/FindShop/getRecommendShopList', ['method' => 'get|post']],
'uploadImg' => ['api/UploadImg/uploadImg', ['method' => 'POST|GET']], //图片上传
]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment