public function uploadsMost(Request $image){
if($image->isPost()){
//dump($image);exit;
$busid=$image->param('busid');
$res=Db::table('xc_ceshi')->where('busid',$busid)->select();
if(!$res){
$ma=Db::table('xc_ceshi')->insert(['busid'=>$busid]);
}
$files = request()->file('image');
$data = [];
foreach($files as $file){
// 移动到框架应用根目录/public/uploads/ 目录下
$info = $file->move(ROOT_PATH . 'public' . DS . 'uploads');
if($info){
$res= $info->getSaveName();
$rest = substr("$res", 0, -37);
$resti = substr("$res", -36, 36);
$km='/';
$mm='http://yfj.sharexwd.top/uploads/';
$file="$mm" . "$rest" . "$km" . "$resti";
$data[] = $file;
}else{
// 上传失败获取错误信息
echo $file->getError();
}
}
$where['path'] = json_encode($data);
$upceshi=Db::table('xc_ceshi')->where(['busid'=>$busid])->update($where);
return $this->fetch('orders/ceshi');
}
return $this->fetch('orders/ceshi');
}
thinkphp5多图片上传并插入到数据库
最新推荐文章于 2023-10-04 16:48:02 发布