引入 use think\File; public function upload() { $file = request()->file('data'); $fileInfo = pathinfo($file); $tmp = $fileInfo['dirname'].'/'.$fileInfo['basename']; $saveName = $file->getOriginalName(); $savePath = root_path().'public/storage/'; $file = new File($tmp); $file = $file->move($savePath, $saveName); /*$file 是对象, $tmp : 上传缓存地址 $savePath: 文件保存地址 $saveName: 文件保存名称 */ }