public function index(){
$ub_id = input("ub_id");
$index = input("index");
$uo_long = input("uo_long");
$uo_lat = input("uo_lat");
$uo_high = input("uo_high");
$current = time();
if(!$this->CheckSession($ub_id,$uo_long,$uo_lat,$uo_high,$current)){
$this->data['result']['sid'] = md5($ub_id);
$this->data['result']['index'] = $index;
return $this->ErrorMsg("01","用户已下线");
}else{
$file = request()->file("image");
$path_dir = ROOT_PATH.'public'.DS.'upload';
$current = time();
$slashTime = date("Y/m/d",$current);
$bareTime = date("Ymd",$current);
$outlineTime = date("Y_m_d",$current);
$createTime = date("Y-m-d H:i:s",$current);
if(empty($ub_id)){
$ub_id = 0;
$path = $path_dir.DS.'pub';
foreach($file as $val){
$info = $val->move($path);
if($info) {
$inf = "文件上传成功";
$this->Online($ub_id,$uo_long,$uo_lat,$uo_high,$inf,$current);
$savePath = $info->getPath();
$extension = $info->getExtension();
$name = $info->getFilename();
$size = $info->getSize();
$fileId = $ub_id."_".$outlineTime.'_'.md5($ub_id.$bareTime.$name);
$fileName = str_replace('/', '\\', $savePath .DS .md5($ub_id.$bareTime.$name) . '.' . $extension);
$fileInfo = str_replace("/", '\\', $savePath .DS .md5($ub_id.$bareTime.$name) . '.' . "inf");
$demo = $ub_id;
$file_ids['fileid'] = $fileId;
$file_ids['filename'] = $fileName;
$res = fopen($fileInfo, 'a+');
fwrite($res, $createTime);
fwrite($res, "\n");
fwrite($res, $fileName);
fwrite($res, "\n");
fwrite($res, $fileId);
fwrite($res, "\n");
fwrite($res, $size);
fwrite($res, "\n");
fwrite($res, $demo);
$url = "http://hb.lchtime.com/upload/pub/".str_replace("_","/",str_replace("0","",$fileId)).".".$extension;
$this->data['file_ids'][] = $file_ids;
$this->data['url'] = $url;
return $this->Sucess("10","文件上传成功!");
}else{
$info = "文件上传失败";
$this->Online($ub_id,$uo_long,$uo_lat,$uo_high,$info,$current);
return $this->ErrorMsg("02","文件上传失败!");
}
}
}else{
$path = $path_dir.DS.$ub_id;
foreach($file as $val){
$info = $val->move($path,true,false);
if($info){
$inf = "文件上传成功";
$this->Online($ub_id,$uo_long,$uo_lat,$uo_high,$inf,$current);
$savePath = $info->getPath();
$extension = $info->getExtension();
$name = $info->getFilename();
$size = $info->getSize();
$fileId = $ub_id."_".$outlineTime.'_'.str_replace(".$extension","",$name);
$fileName = str_replace('/', '\\', $savePath .DS .$name);
$fileInfo = str_replace("$extension", "inf", $fileName);
$demo = $ub_id;
$file_ids['fileid'] = $fileId;
$file_ids['filename'] = $fileName;
$res = fopen($fileInfo, 'a+');
fwrite($res, $createTime);
fwrite($res, "\n");
fwrite($res, $fileName);
fwrite($res, "\n");
fwrite($res, $fileId);
fwrite($res, "\n");
fwrite($res, $size);
fwrite($res, "\n");
fwrite($res, $demo);
$userDetail = new UserDetail;
$userDetail->where('ud_ub_id',$ub_id)->update(["ud_photo_fileid"=>$fileId]);
$url = "http://hb.lchtime.com/upload/".str_replace("_","/",$fileId).".".$extension;
$this->data['result']['sid'] =md5($ub_id);
$this->data['result']['index'] = $index;
$this->data['file_ids'][] = $file_ids;
$this->data['url'] = $url;
return $this->Sucess("10","文件上传成功!");
}else{
$info = "文件上传失败";
$this->Online($ub_id,$uo_long,$uo_lat,$uo_high,$info,$current);
$this->data['result']['sid'] = md5($ub_id);
$this->data['result']['index'] = $index;
return $this->ErrorMsg("02","文件上传失败!");
}
}
}
}
}