文件上传
public function insert(Request $request){ $name = $request->param('name'); $age = $request->param('age'); $dress = $request->param('dress'); $img = $request->file('img'); $time = $request->param('time'); if ($img){ //文件上传 $file = \think\facade\Filesystem::disk('public')->putFile('',$img); $path = "./image/".$file; //缩略图 $image = Image::open($path); $image->thumb(50,50)->save($path.".png"); //水印图 $waterFile = "./water/".time().rand(1000,9999).".jpg"; $image->text('2022',realpath('SIMSUN.TTC'),'10','#ff0000')->save($waterFile); } $data = [ 'name'=>$name, 'age'=>$age, 'dress'=>$dress, 'time'=>$time, 'img'=>$file, 'imgs'=>$path.".png", 'imgss'=>$waterFile, ]; $shi = new DayMod(); $res = $shi->add($data);