Commit 0432f038 authored by hujun's avatar hujun

userId to agentId

parent d172d52b
...@@ -326,24 +326,21 @@ class Broker extends Basic ...@@ -326,24 +326,21 @@ class Broker extends Basic
$info = $file->validate(['size'=>512000,'ext'=>'jpg,png']) //限制500KB $info = $file->validate(['size'=>512000,'ext'=>'jpg,png']) //限制500KB
->move($path); ->move($path);
if($info){ if($info){
if ($this->userId) { $user = new AAgents();
$user = new AAgents(); $user_data = $user->field('img')->where('id',$this->agentId)->find();
$user_data = $user->field('img')->where('id',$this->userId)->find(); @unlink($path.DS.$user_data->img); //删除原来的图片
@unlink($path.DS.$user_data->img); //删除原来的图片 $img_path = $info->getSaveName(); //生成的图片路径
$img_path = $info->getSaveName(); //生成的图片路径 //更新用户信息
//更新用户信息 $user_data->img = $img_path;
$user_data->img = $img_path; $user_data->save();
$user_data->save();
$static_path = $path.DS.$img_path; //生成图片的绝对路径
$static_path = $path.DS.$img_path; //生成图片的绝对路径 $image = \think\Image::open($static_path);
$image = \think\Image::open($static_path); $image->thumb(500, 500)->save($static_path); //生成缩略图
$image->thumb(500, 500)->save($static_path); //生成缩略图
$data['status'] = 200;
$data['status'] = 200; $data['msg'] = '上传成功';
$data['msg'] = '上传成功'; $data['data'] = ['file_name' => HEADERIMGURL . $img_path];
$data['data'] = ['file_name' => HEADERIMGURL . $img_path];
}
}else{ }else{
// 上传失败获取错误信息 // 上传失败获取错误信息
$data['msg'] = $file->getError(); $data['msg'] = $file->getError();
......
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