作者 liyuhang

gx

@@ -113,11 +113,13 @@ class ImageController @@ -113,11 +113,13 @@ class ImageController
113 if ($res === false) { 113 if ($res === false) {
114 return $this->fail($image->getError(), 400); 114 return $this->fail($image->getError(), 400);
115 } 115 }
  116 + var_dump($res);
  117 + die();
116 $data = [ 118 $data = [
117 'path' => $url.$filename, 119 'path' => $url.$filename,
118 'created_at' => date('Y-m-d H:i:s',time()), 120 'created_at' => date('Y-m-d H:i:s',time()),
119 'size' => $res->getSize(), 121 'size' => $res->getSize(),
120 - 'hash' => hash(), 122 + 'hash' => $res->getHash(),
121 ]; 123 ];
122 $imageModel = new ImageModel(); 124 $imageModel = new ImageModel();
123 $imageModel->add($data); 125 $imageModel->add($data);
@@ -30,11 +30,6 @@ class UserLogic extends BaseLogic @@ -30,11 +30,6 @@ class UserLogic extends BaseLogic
30 } 30 }
31 //密码加密 31 //密码加密
32 $this->param['password'] = base64_encode(md5($this->param['password'])); 32 $this->param['password'] = base64_encode(md5($this->param['password']));
33 - //上传头像  
34 - if(isset($this->param['image'])){  
35 - $data = $this->upload();  
36 - $this->param['image'] = $data['hash'];  
37 - }  
38 $rs = $this->model->add($this->param); 33 $rs = $this->model->add($this->param);
39 if($rs === false){ 34 if($rs === false){
40 $this->fail('error',Code::USER_ERROR); 35 $this->fail('error',Code::USER_ERROR);
@@ -55,11 +50,6 @@ class UserLogic extends BaseLogic @@ -55,11 +50,6 @@ class UserLogic extends BaseLogic
55 if($info !== false){ 50 if($info !== false){
56 $this->fail('当前编辑的手机号码已存在',Code::USER_PARAMS_ERROE); 51 $this->fail('当前编辑的手机号码已存在',Code::USER_PARAMS_ERROE);
57 } 52 }
58 - //上传头像  
59 - if(isset($this->param['image'])){  
60 - $data = $this->upload();  
61 - $this->param['image'] = $data['hash'];  
62 - }  
63 $this->param['operator_id'] = $this->user['id']; 53 $this->param['operator_id'] = $this->user['id'];
64 $rs = $this->model->edits($this->param); 54 $rs = $this->model->edits($this->param);
65 if($rs === false){ 55 if($rs === false){
@@ -155,6 +155,9 @@ Route::middleware(['bloginauth'])->group(function () { @@ -155,6 +155,9 @@ Route::middleware(['bloginauth'])->group(function () {
155 Route::prefix('file')->group(function () { 155 Route::prefix('file')->group(function () {
156 Route::post('/upload', [\App\Http\Controllers\Bside\FileController::class, 'upload'])->name('file_upload'); 156 Route::post('/upload', [\App\Http\Controllers\Bside\FileController::class, 'upload'])->name('file_upload');
157 }); 157 });
  158 + Route::prefix('image')->group(function () {
  159 + Route::post('/upload', [\App\Http\Controllers\ImageController::class, 'upload'])->name('image_upload');
  160 + });
158 }); 161 });
159 162
160 //无需登录验证的路由组 163 //无需登录验证的路由组