Commit 088c36fe authored by hujun's avatar hujun

app上传图片文件

parent dcb8068f
......@@ -265,4 +265,42 @@ class Shop extends Basic
return $this->response($result['code'], $result['msg'], $result['data']);;
}
/**
* 上传头像
*
* @return \think\Response
*/
public function uploadHouseFile() {
$data['status'] = 101;
$data['msg'] = '';
$data['data'] = '';
$file = request()->file('file');
if($file){
$path = ROOT_PATH . 'public' . DS . 'resource'. DS . 'lib'. DS .'Attachments'. DS .'images'. DS . 'app_housesFile';
$info = $file->validate(['size'=>1024000,'ext'=>'jpg,png'])->move($path);
if($info){
// if ($this->userId) {
// $user_data = $this->gHousesImgModel->field('img_name')->where('id',$this->agentId)->find();
// @unlink($path.DS.$user_data->user_pic); //删除原来的图片
$img_path = $info->getSaveName(); //生成的图片路径
$data['status'] = 200;
$data['msg'] = '上传成功';
$data['data'] = [
'file_name' => CK_IMG_URL .'images'. DS .'app_housesFile'. DS . $img_path,
'save_path' => 'app_housesFile/'.$img_path
];
// }
}else{
// 上传失败获取错误信息
$data['msg'] = $file->getError();
}
} else {
$data['msg'] = '没有该文件';
}
return $this->response($data['status'], $data['msg'], $data['data']);
}
}
......@@ -192,7 +192,6 @@ class Houses extends Basic
$data['data']['list'] = $this->house->getHouseListDish($pageNo, $pageSize, 'a.id DESC', $fields, $where, $this->userId);
$data['data']['total'] = $this->house->getHouseListDishTotal($where);
}
$data['data']['auth_c'] = Session::get('user_info.auth');
return $this->response($data['status'], $data['msg'], $data['data']);
}
......
......@@ -325,6 +325,7 @@ Route::group('broker', [
'center' => ['api_broker/MyCenter/center', [ 'method' => 'get|post' ] ],
'houseEdit' => ['api_broker/shop/edit', ['method' => 'get|post']], //编辑商铺
'getLabelsShopList' => ['api_broker/label/getLabelsShopList', ['method' => 'get']], //编辑商铺
'uploadHouseFile' => ['api_broker/shop/uploadHouseFile', ['method' => 'post']], //商铺上传文件
]);
//Route::miss('api/index/miss');//处理错误的url
\ No newline at end of file
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