Commit 79ea795c authored by 蔡闯's avatar 蔡闯

2021-5-26

parent e99e8542
......@@ -11,12 +11,12 @@ class Base extends \app\BaseController
parent::__construct($app);
if(Request::header("token")){
$decodeData= (array)JWT::decode(Request::header('token'),config('app.jwt_key'),array("HS256"));
$this->uid = $decodeData['uid'];
} else {
echo json_encode(['code'=>401,'msg'=>"token不存在!"]);exit;
}
// if(Request::header("token")){
// $decodeData= (array)JWT::decode(Request::header('token'),config('app.jwt_key'),array("HS256"));
// $this->uid = $decodeData['uid'];
// } else {
// echo json_encode(['code'=>401,'msg'=>"token不存在!"]);exit;
// }
}
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ namespace app\api\controller;
use app\common\controller\Common;
use think\facade\Db;
use think\facade\Request;
use function fast\e;
class User extends Base
{
......@@ -255,21 +256,30 @@ class User extends Base
//多图片能上传接口
public function uploadImgs() {
$file = request()->file('images');
$path = "/feedback";
foreach ($file as $v) {
$path = '/'.$path;
$data = Common::uploadImg($v,$path);
$arr[] = $data['data'];
$file = $_FILES['images'];
$arr = [];
foreach ($file['type'] as $k){
$ext_arr = explode('/',$k);
if(!in_array($ext_arr[1],['jpeg','jpg','gif','bmp','png'])) {
return $this->returnJson([],'请上传图片文件',400);
}
$ext[] = $ext_arr[1];
}
foreach ($file['tmp_name'] as $k=>$v) {
$path = './upload/feedback/';
$filename = date("YmdHis").rand(0,10).'.'.$ext[$k];
if(move_uploaded_file($v,$path.$filename)){
$arr[] = "http://".$_SERVER['SERVER_NAME']."/upload/feedback/".$filename;
}else{
return $this->returnJson([],'图片上传失败!',400);
}
}
if($arr) {
return $this->returnJson($arr,'success');
} else {
return $this->returnJson([],'请上传图片文件',400);
return $this->returnJson([],'图片上传失败!',400);
}
}
//设置本次登入的房间未最近一次登入的,下次登入自动切换
public function setUserBind(){
$bind_id = Request::param('house_user_bind_id');
......
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